diff --git a/src/components/avatar/avatar.vue b/src/components/avatar/avatar.vue index 91285f14..a40368c6 100644 --- a/src/components/avatar/avatar.vue +++ b/src/components/avatar/avatar.vue @@ -45,7 +45,8 @@ prefixCls: prefixCls, scale: 1, childrenWidth: 0, - isSlotShow: false + isSlotShow: false, + slotTemp: null }; }, computed: { @@ -85,6 +86,11 @@ return style; } }, + watch: { + size: function (val, oldVal) { + if (val !== oldVal) this.setScale(); + }, + }, methods: { setScale () { this.isSlotShow = !this.src && !this.icon; @@ -104,11 +110,17 @@ this.$emit('on-error', e); } }, + beforeCreate () { + this.slotTemp = this.$slots.default; + }, mounted () { this.setScale(); }, updated () { - this.setScale(); + if (this.$slots.default !== this.slotTemp) { + this.slotTemp = this.$slots.default; + this.setScale(); + } } };