From 2fdb2ff2615ccb3626ed1ec950ee541cbfaaaa21 Mon Sep 17 00:00:00 2001 From: wangyaqi Date: Fri, 6 Dec 2019 18:10:58 +0800 Subject: [PATCH] =?UTF-8?q?update(v3):=20image=E7=BB=84=E4=BB=B6@error?= =?UTF-8?q?=E6=8B=89=E9=BD=90=E5=BE=AE=E4=BF=A1=E5=B0=8F=E7=A8=8B=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/view/components/image/index.vue | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/core/view/components/image/index.vue b/src/core/view/components/image/index.vue index 6c4a73cc..54a3fca9 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) { -- GitLab