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

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

上级 b55bc68b
<template> <template>
<uni-image v-on="$listeners"> <uni-image v-on="$listeners">
<div <div
ref="content" ref="content"
:style="modeStyle" /> :style="modeStyle" />
<img :src="realImagePath"> <img :src="realImagePath">
<v-uni-resize-sensor <v-uni-resize-sensor
v-if="mode === 'widthFix'" v-if="mode === 'widthFix'"
ref="sensor" ref="sensor"
@resize="_resize" /> @resize="_resize" />
</uni-image> </uni-image>
</template> </template>
...@@ -41,7 +41,7 @@ export default { ...@@ -41,7 +41,7 @@ export default {
return this.originalWidth && this.originalHeight ? this.originalWidth / this.originalHeight : 0 return this.originalWidth && this.originalHeight ? this.originalWidth / this.originalHeight : 0
}, },
realImagePath () { realImagePath () {
return this.$getRealPath(this.src) return this.src && this.$getRealPath(this.src)
}, },
modeStyle () { modeStyle () {
let size = 'auto' let size = 'auto'
...@@ -128,7 +128,7 @@ export default { ...@@ -128,7 +128,7 @@ export default {
} }
}, },
_loadImage () { _loadImage () {
this.$refs.content.style.backgroundImage = `url(${this.realImagePath})` this.$refs.content.style.backgroundImage = this.src ? `url(${this.realImagePath})` : 'none'
const _self = this const _self = this
const img = new Image() const img = new Image()
...@@ -197,4 +197,4 @@ export default { ...@@ -197,4 +197,4 @@ export default {
uni-image>.uni-image-will-change { uni-image>.uni-image-will-change {
will-change: transform; will-change: transform;
} }
</style> </style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册