1
+ import { inject } from 'vue' ;
1
2
import { ConfigConsumerProps } from '../config-provider' ;
2
- import { getListeners , getComponentFromProp } from '../_util/props-util' ;
3
+ import { getComponent } from '../_util/props-util' ;
3
4
import PropTypes from '../_util/vue-types' ;
4
5
5
6
export default {
@@ -26,8 +27,10 @@ export default {
26
27
alt : String ,
27
28
loadError : Function ,
28
29
} ,
29
- inject : {
30
- configProvider : { default : ( ) => ConfigConsumerProps } ,
30
+ setup ( ) {
31
+ return {
32
+ configProvider : inject ( 'configProvider' , ConfigConsumerProps ) ,
33
+ } ;
31
34
} ,
32
35
data ( ) {
33
36
return {
@@ -87,7 +90,7 @@ export default {
87
90
} ,
88
91
render ( ) {
89
92
const { prefixCls : customizePrefixCls , shape, size, src, alt, srcSet } = this . $props ;
90
- const icon = getComponentFromProp ( this , 'icon' ) ;
93
+ const icon = getComponent ( this , 'icon' ) ;
91
94
const getPrefixCls = this . configProvider . getPrefixCls ;
92
95
const prefixCls = getPrefixCls ( 'avatar' , customizePrefixCls ) ;
93
96
@@ -116,7 +119,7 @@ export default {
116
119
}
117
120
: { } ;
118
121
119
- let children = this . $slots . default ;
122
+ let children = this . $slots . default && this . $slots . default ( ) ;
120
123
if ( src && isImgExist ) {
121
124
children = < img src = { src } srcSet = { srcSet } onError = { this . handleImgLoadError } alt = { alt } /> ;
122
125
} else if ( icon ) {
@@ -158,7 +161,7 @@ export default {
158
161
}
159
162
}
160
163
return (
161
- < span ref = "avatarNode" { ...{ on : getListeners ( this ) , class : classString , style : sizeStyle } } >
164
+ < span ref = "avatarNode" { ...{ class : classString , style : sizeStyle } } >
162
165
{ children }
163
166
</ span >
164
167
) ;
0 commit comments