html:
<el-table :data="list" row-key="id" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55"/>
</el-table>
js变量:
data () {
return {
// 多选选择的数组
selectArray: []
}
},
js方法:
/**
* 多选
*/
handleSelectionChange(data) {
let res = this.selectArray;
this.list.forEach((item, index) => {
this.selectArray.forEach((items, indexs) => {
if (item['id'] == items) res.splice(indexs, 1);
});
});
if(data.length > 0) {
data.map(item => {
res.push(item.id);
});
};
this.selectArray = res;
}
效果图: