Item.jsx 853 B

12345678910111213141516171819202122232425
  1. import PropTypes from 'ant-design-vue/es/_util/vue-types'
  2. import { Tooltip, Avatar } from 'ant-design-vue'
  3. import { getSlotOptions } from 'ant-design-vue/lib/_util/props-util'
  4. import { warning } from 'ant-design-vue/lib/vc-util/warning'
  5. export const AvatarListItemProps = {
  6. tips: PropTypes.string,
  7. src: PropTypes.string.def('')
  8. }
  9. const Item = {
  10. __ANT_AVATAR_CHILDREN: true,
  11. name: 'AvatarListItem',
  12. props: AvatarListItemProps,
  13. created () {
  14. warning(getSlotOptions(this.$parent).__ANT_AVATAR_LIST, 'AvatarListItem must be a subcomponent of AvatarList')
  15. },
  16. render () {
  17. const size = this.$parent.size === 'mini' ? 'small' : this.$parent.size
  18. const AvatarDom = <Avatar size={size || 'small'} src={this.src} />
  19. return (this.tips && <Tooltip title={this.tips}>{AvatarDom}</Tooltip>) || <AvatarDom />
  20. }
  21. }
  22. export default Item