直接贴代码
toDeleteRow() {
this.$refs.tableData.selection.sort(function (a,b) {
// 按照index升序
return a.index - b.index
})
// console.log(this.$refs.tableData.selection);
if (this.$refs.tableData.selection.length > 0) {
for (let i = this.$refs.tableData.selection.length-1; i >= 0 ; i--) {
this.tableData.forEach(el => {
if(el.index == this.$refs.tableData.selection[i].index ){
console.log('ok');
this.tableData.splice(el.index,1);
return ;
}
});
}
} else {
this.$message({
type: "error",
message: "请选择一条数据!"
});
}
},