分页也可 记录 已勾选的

mac2023-01-23  32

// 分页勾选 记录 已勾选的 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: { // 判断当前li是否勾选 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" }); } }, }
最新回复(0)