1.el-table结合el-pagination,在翻页之后再返回勾选的数据状态会消失,解决办法:
<el-table-column type="selection" width="55" :reserve-selection="true">
<el-table
stripe
ref="multipleTable"
:data="tableList"
tooltip-effect="dark"
style="width: 60%; position: absolute; top: 30px; left: 30px"
height="400px"
@selection-change="handleSelectionChange"
:row-key="rowKey"
>
给selection行加上:reserve-selection="true";
给el-table加上:row-key="rowKey";
两者缺一不可;
2.拿到每页所勾选的数据,使用watch函数,el-table上绑定的选中函数@selection-change="handleSelectionChange";
handleSelectionChange(val) {
this.multipleSelection = val;
},
将val赋值给data中的一个数组,在watch函数中监听这个数据即可
watch: {
multipleSelection(newValue, oldValue) {
console.log(newValue);
},
},