diff --git a/src/core/view/components/image/index.vue b/src/core/view/components/image/index.vue index 6c4a73cc6932cf5e778e87923cd627a225e49cb9..54a3fca9e760ed20e58d98e21eaa9ea92332d667 100644 --- a/src/core/view/components/image/index.vue +++ b/src/core/view/components/image/index.vue @@ -97,7 +97,8 @@ export default { } }, watch: { - src (newValue, oldValue) { + src (newValue, oldValue) { + this._setContentImage() this._loadImage() }, mode (newValue, oldValue) { @@ -111,7 +112,11 @@ export default { } }, mounted () { - this.availHeight = this.$el.style.height || '' + this.availHeight = this.$el.style.height || '' + this._setContentImage() + if (!this.realImagePath) { + return + } this._loadImage() }, methods: { @@ -131,10 +136,11 @@ export default { this.$el.style.height = height + 'px' this.sizeFixed = true } + }, + _setContentImage () { + this.$refs.content.style.backgroundImage = this.src ? `url(${this.realImagePath})` : 'none' }, _loadImage () { - this.$refs.content.style.backgroundImage = this.src ? `url(${this.realImagePath})` : 'none' - const _self = this const img = new Image() img.onload = function ($event) {