【发布时间】:2021-02-01 22:59:37
【问题描述】:
我正在使用元素 ui el-image。我想在单击 (:preview-src-list) 时预览我的图像。但是当我第一次单击时,它不会预览任何内容。只需添加我下载的图像。所以我需要点击2次。但是我想点击1次。
这是我的模板代码:
<el-image :src="src"
:preview-src-list="srcList"
@click="imgClick"></el-image>
ts 代码:
src = null;
srcList = [];
product = 'shoe1';
imgClick() {
prevImg(product).then(resp => {
const url = window.URL.createObjectURL(new Blob([resp.data]));
this.srclist = [url];
});
}
@Watch("product")
changed(value) {
getProductImage(value).then(resp => {
const url = window.URL.createObjectURL(new Blob([resp.data]));
this.src = url;
}).catc(e => {
alert(e);
});
}
mounted() {
this.changed(product);
}
【问题讨论】:
标签: vue.js vuejs2 vue-component element-ui