inleft
2022-02-09 9bcb19959eeb9da9bde2561e7278f6d0a55eb151
commit | author | age
9bcb19 1 <template>
I 2   <tooltip v-if="tips !== ''">
3     <template slot="title">{{ tips }}</template>
4     <avatar :size="avatarSize" :src="src" />
5   </tooltip>
6   <avatar v-else :size="avatarSize" :src="src" />
7 </template>
8
9 <script>
10 import Avatar from 'ant-design-vue/es/avatar'
11 import Tooltip from 'ant-design-vue/es/tooltip'
12
13 export default {
14   name: 'AvatarItem',
15   components: {
16     Avatar,
17     Tooltip
18   },
19   props: {
20     tips: {
21       type: String,
22       default: '',
23       required: false
24     },
25     src: {
26       type: String,
27       default: ''
28     }
29   },
30   data () {
31     return {
32       size: this.$parent.size
33     }
34   },
35   computed: {
36     avatarSize () {
37       return this.size !== 'mini' && this.size || 20
38     }
39   },
40   watch: {
41     '$parent.size' (val) {
42       this.size = val
43     }
44   }
45 }
46 </script>