// 这个是阻止冒泡的
当前位置:   article > 正文

分页也可 记录 已勾选的_分页全部勾选

分页全部勾选
// 分页勾选 记录 已勾选的
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"
        });
      }
    },
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/article/detail/49184
推荐阅读
相关标签
  

闽ICP备14008679号