vue3使用element-plus,解决 el-table 多选框,选中后翻页再回来选中失效问题
问题:勾选的数据分页再回来回消失
1.在el-table中加 :row-key="getRowKey"
const getRowKey = (row) => {
return row.id; // id必须是唯一的
};
2.给type为selection的el-table-column添加上reserve-selection属性
<el-table
ref="multipleTableRef"
border
:data="data.rows"
@selection-change="handleSelectionChange"
v-loading="data.dataListLoading"
element-loading-text="数据加载中..."
:row-key="getRowKey"
>
<el-table-column type="selection" reserve-selection width="55" />
</el-table>
const getRowKey = (row) => {
return row.id;
};