html
:
<span @click
.stop
="">
<svg @click
.stop
="insertImage(item)" class
="icon" aria
-hidden
="true">
<use
:xlink
:href
="isCheck(item.id)"></use
>
</svg
>
</span
>
js
:
data() {
return {
icon
: {
circle
: "#iconfuxuankuang_weixuanzhong",
correct
: "#iconfuxuankuang_xuanzhong"
}
}
},
computed
: {
isCheck() {
return id
=> {
let index
= this
.imageArrays
.findIndex(
item
=> item
.fileid
=== id
);
return index
< 0
? this
.icon
.circle
: this
.icon
.correct
;
};
},
},
methods
: {
insertImage(row
) {
let index
= this
.imageArrays
.findIndex(
item
=> item
.fileid
== row
.id
);
if (index
< 0) {
let image
= ......
this
.imageArrays
.push(image
);
this
.$
message({
message
: "您已选择该图片,请点击右下角确定进行插入!",
type
: "success"
});
} else {
this
.imageArrays
.splice(index
, 1);
this
.$
message({
message
: "您已取消选中该图片",
type
: "error"
});
}
},
}
转载请注明原文地址: https://mac.8miu.com/read-452070.html