@@ -2,6 +2,7 @@ import { tuple, VueNode } from '../_util/type';
2
2
import {
3
3
CSSProperties ,
4
4
defineComponent ,
5
+ ExtractPropTypes ,
5
6
inject ,
6
7
nextTick ,
7
8
onMounted ,
@@ -14,19 +15,28 @@ import { defaultConfigProvider } from '../config-provider';
14
15
import { getPropsSlot } from '../_util/props-util' ;
15
16
import PropTypes from '../_util/vue-types' ;
16
17
17
- export interface AvatarProps {
18
- prefixCls ?: string ;
19
- shape ?: 'circle' | 'square' ;
20
- size ?: 'large' | 'small' | 'default' | number ;
21
- src ?: string ;
22
- srcset ?: string ;
23
- icon ?: typeof PropTypes . VNodeChild ;
24
- alt ?: string ;
25
- loadError ?: ( ) => boolean ;
26
- }
27
-
28
- const Avatar = defineComponent < AvatarProps > ( {
18
+ const avatarProps = {
19
+ prefixCls : PropTypes . string ,
20
+ shape : PropTypes . oneOf ( tuple ( 'circle' , 'square' ) ) ,
21
+ size : {
22
+ type : [ Number , String ] as PropType < 'large' | 'small' | 'default' | number > ,
23
+ default : 'default' ,
24
+ } ,
25
+ src : PropTypes . string ,
26
+ /** Srcset of image avatar */
27
+ srcset : PropTypes . string ,
28
+ icon : PropTypes . VNodeChild ,
29
+ alt : PropTypes . string ,
30
+ loadError : {
31
+ type : Function as PropType < ( ) => boolean > ,
32
+ } ,
33
+ } ;
34
+
35
+ export type AvatarProps = Partial < ExtractPropTypes < typeof avatarProps > > ;
36
+
37
+ const Avatar = defineComponent ( {
29
38
name : 'AAvatar' ,
39
+ props : avatarProps ,
30
40
setup ( props , { slots } ) {
31
41
const isImgExist = ref ( true ) ;
32
42
const isMounted = ref ( false ) ;
@@ -73,7 +83,6 @@ const Avatar = defineComponent<AvatarProps>({
73
83
nextTick ( ( ) => {
74
84
isImgExist . value = true ;
75
85
scale . value = 1 ;
76
- // this.$forceUpdate();
77
86
} ) ;
78
87
} ,
79
88
) ;
@@ -163,21 +172,4 @@ const Avatar = defineComponent<AvatarProps>({
163
172
} ,
164
173
} ) ;
165
174
166
- Avatar . props = {
167
- prefixCls : PropTypes . string ,
168
- shape : PropTypes . oneOf ( tuple ( 'circle' , 'square' ) ) ,
169
- size : {
170
- type : [ Number , String ] as PropType < 'large' | 'small' | 'default' | number > ,
171
- default : 'default' ,
172
- } ,
173
- src : PropTypes . string ,
174
- /** Srcset of image avatar */
175
- srcset : PropTypes . string ,
176
- icon : PropTypes . VNodeChild ,
177
- alt : PropTypes . string ,
178
- loadError : {
179
- type : Function as PropType < ( ) => boolean > ,
180
- } ,
181
- } ;
182
-
183
175
export default Avatar ;
0 commit comments