el-table使用checkbox时,获取选中数据的id?

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

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

   

posted @ 2021-07-11 16:19  钟小嘿  阅读(2363)  评论(0编辑  收藏  举报