提交 2294e8a8 编写于 作者: Q qiang

fix: 解决 H5 端 image 组件 src 为空时产生错误的资源请求

上级 b55bc68b
<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>
......@@ -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'
......@@ -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()
......@@ -197,4 +197,4 @@ export default {
uni-image>.uni-image-will-change {
will-change: transform;
}
</style>
</style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册