uni-app image标签 404错误之后替换为默认图片
<template>
<view v-for="(item, index) in Items" :key="index">
<image :src="item.imgUrl" mode="aspectFill" @error="error(index)"></image>
</view>
</template>
<script>
export default {
data() {
return {
Items: []//请求返回的数据
}
},
methods: {
error: function(index) { //加载图片出现404错误之后用默认图片替换
this.Items[index]['imgUrl'] = '../../static/logo.png'; //默认图片路径
}
}
}
</script>

浙公网安备 33010602011771号