Skip to content

Commit

Permalink
fix: 解决 H5 端 image 组件 src 为空时产生错误的资源请求
Browse files Browse the repository at this point in the history
  • Loading branch information
zhetengbiji committed Jun 3, 2019
1 parent b55bc68 commit 2294e8a
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/core/view/components/image/index.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<template>
<uni-image v-on="$listeners">
<div
ref="content"
<div
ref="content"
:style="modeStyle" />
<img :src="realImagePath">
<v-uni-resize-sensor
v-if="mode === 'widthFix'"
ref="sensor"
<v-uni-resize-sensor
v-if="mode === 'widthFix'"
ref="sensor"
@resize="_resize" />
</uni-image>
</template>
Expand Down Expand Up @@ -41,7 +41,7 @@ export default {
return this.originalWidth && this.originalHeight ? this.originalWidth / this.originalHeight : 0
},
realImagePath () {
return this.$getRealPath(this.src)
return this.src && this.$getRealPath(this.src)
},
modeStyle () {
let size = 'auto'
Expand Down Expand Up @@ -128,7 +128,7 @@ export default {
}
},
_loadImage () {
this.$refs.content.style.backgroundImage = `url(${this.realImagePath})`
this.$refs.content.style.backgroundImage = this.src ? `url(${this.realImagePath})` : 'none'
const _self = this
const img = new Image()
Expand Down Expand Up @@ -197,4 +197,4 @@ export default {
uni-image>.uni-image-will-change {
will-change: transform;
}
</style>
</style>

0 comments on commit 2294e8a

Please sign in to comment.