diff --git a/components/avatar/Avatar.jsx b/components/avatar/Avatar.jsx
index d64cc3788e..1d1be9fa5c 100644
--- a/components/avatar/Avatar.jsx
+++ b/components/avatar/Avatar.jsx
@@ -1,5 +1,6 @@
+import { inject } from 'vue';
import { ConfigConsumerProps } from '../config-provider';
-import { getListeners, getComponentFromProp } from '../_util/props-util';
+import { getComponent } from '../_util/props-util';
import PropTypes from '../_util/vue-types';
export default {
@@ -26,8 +27,10 @@ export default {
alt: String,
loadError: Function,
},
- inject: {
- configProvider: { default: () => ConfigConsumerProps },
+ setup() {
+ return {
+ configProvider: inject('configProvider', ConfigConsumerProps),
+ };
},
data() {
return {
@@ -87,7 +90,7 @@ export default {
},
render() {
const { prefixCls: customizePrefixCls, shape, size, src, alt, srcSet } = this.$props;
- const icon = getComponentFromProp(this, 'icon');
+ const icon = getComponent(this, 'icon');
const getPrefixCls = this.configProvider.getPrefixCls;
const prefixCls = getPrefixCls('avatar', customizePrefixCls);
@@ -116,7 +119,7 @@ export default {
}
: {};
- let children = this.$slots.default;
+ let children = this.$slots.default && this.$slots.default();
if (src && isImgExist) {
children =
;
} else if (icon) {
@@ -158,7 +161,7 @@ export default {
}
}
return (
-
+
{children}
);
diff --git a/components/avatar/index.js b/components/avatar/index.js
index c8e6fb99b5..72d914710f 100644
--- a/components/avatar/index.js
+++ b/components/avatar/index.js
@@ -1,10 +1,8 @@
import Avatar from './Avatar';
-import Base from '../base';
/* istanbul ignore next */
-Avatar.install = function(Vue) {
- Vue.use(Base);
- Vue.component(Avatar.name, Avatar);
+Avatar.install = function(app) {
+ app.component(Avatar.name, Avatar);
};
export default Avatar;
diff --git a/examples/index.js b/examples/index.js
index 28577de5fd..430e34f0e1 100644
--- a/examples/index.js
+++ b/examples/index.js
@@ -1,6 +1,7 @@
import '@babel/polyfill';
import { createApp } from 'vue';
import App from './App.vue';
+import Avatar from 'ant-design-vue/avatar';
import Button from 'ant-design-vue/button';
import Drawer from 'ant-design-vue/drawer';
import Affix from 'ant-design-vue/affix';
@@ -11,6 +12,7 @@ import Empty from 'ant-design-vue/empty';
import 'ant-design-vue/style.js';
createApp(App)
+ .use(Avatar)
.use(Button)
.use(ConfigProvider)
.use(Drawer)