我有使用VuetifyVuejs 2绑定图片src
<v-data-table :headers="headers" :items="items">
<template slot="items" scope="props">
<td>
<img :src="getImgUrl(props.item.styleCode)" />
</td>
</template>
</v-data-table>
多行和<td>
加载动态链接图像表,然后
checkImage(imageSrc, good, bad) {
let img = new Image();
img.onload = good;
img.onerror = bad;
img.src = imageSrc;
},
getImgUrl(styleCode) {
var image = 'http://192.168.1.19/Images/ClassImages/' + styleCode + '.png';
this.checkImage(image,
function() {
return 'http://192.168.1.19/Images/ClassImages/' + styleCode + '.png';
}, function() {
return 'http://192.168.1.19/Images/ClassImages/default.png';
});
}
这任何回报。 什么是我做的不好?
编辑:这是加载外部图像,如果不存在加载默认图像
你”再 – thanksd
这是正常工作,如果我在getImgUrl功能 –