提交 b0c5829e 编写于 作者: 雪洛's avatar 雪洛

fix: 修正错误示例

上级 533daab2
...@@ -8,13 +8,14 @@ ...@@ -8,13 +8,14 @@
<view v-for="(item,index) in data" :key="index"> <view v-for="(item,index) in data" :key="index">
<text class="uni-subtitle-text">{{item.description}}</text> <text class="uni-subtitle-text">{{item.description}}</text>
<view class="uni-center" style="background:#FFFFFF;"> <view class="uni-center" style="background:#FFFFFF;">
<image class="image" mode="widthFix" :src="item.errorImage == null ? item.src : item.errorImage" @error="imageErrorEvent(index, $event as ImageErrorEvent)"></image> <image class="image" mode="widthFix" :src="item.errorImage == null ? item.src : item.errorImage"
@error="imageErrorEvent(index, $event as ImageErrorEvent)"></image>
</view> </view>
</view> </view>
<view> <view>
<text class="uni-subtitle-text">非static目录的src静态路径:./logo.png</text> <text class="uni-subtitle-text">非static目录的src静态路径:./logo.png</text>
<view class="uni-center" style="background:#FFFFFF;"> <view class="uni-center" style="background:#FFFFFF;">
<image class="image" mode="widthFix" :src="outsideStaticErrorPath == null ? outsideStaticPath : outsideStaticErrorPath" @error="imageOutsideStaticErrorEvent"></image> <image class="image" mode="widthFix" src="./logo.png"></image>
</view> </view>
</view> </view>
</view> </view>
...@@ -93,14 +94,10 @@ ...@@ -93,14 +94,10 @@
} }
}, },
methods: { methods: {
imageErrorEvent(index: number, e : ImageErrorEvent) { imageErrorEvent(index : number, e : ImageErrorEvent) {
console.log("图片加载错误", e.detail); console.log("图片加载错误", e.detail);
// 图片加载失败,加载本地占位图 // 图片加载失败,加载本地占位图
this.data[index].errorImage = '/static/template/drop-card/dislike.png' this.data[index].errorImage = '/static/template/drop-card/dislike.png'
},
imageOutsideStaticErrorEvent(e: ImageErrorEvent) {
console.log("图片加载错误", e.detail);
this.outsideStaticErrorPath = '/static/template/drop-card/dislike.png'
} }
}, },
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册