首页 > 技术文章 > el-table使用checkbox时,获取选中数据的id?

zys2019 2021-07-11 16:19 原文

使用checkbox选中时有一个触发事件,那么触发事件可以调用下面的方法:

//多选框选中事件
handleSelectionChange(val) {
       this.multipleSelection = []
       //val是选中的数据的数组
       val.forEach(item => {
           const id = item.id
           //判断数组中是否包含某个值
           if (this.multipleSelection.indexOf(id) == -1) {
               this.multipleSelection.push(id)
           }
       })
}               

   

推荐阅读