表格分页多选记忆功能

今天项目中遇到了表格(支持分页功能)批量删除的问题,在选中部分数据切换到下一页在切换回来的时候发现之前选择的数据并没有显示选中,然后再element官方的文档上写到了这两个属性:

reserve-selection 仅对 type=selection 的列有效,类型为 Boolean,为 true 则会在数据更新之后保留之前选中的数据(需指定 row-key
row-key 行数据的 Key,用来优化 Table 的渲染;在使用 reserve-selection 功能与显示树形数据时,该属性是必填的。类型为 String 时,支持多层访问:user.info.id,但不支持 user.info[0].id,此种情况请使用 Function
<el-table :row-key="rowKey">
     <el-table-column type="selection" :reserve-selection="true"></el-table-column>
</el-table>
methods: {
   rowKey (row) {
      return row.id
    }
}

猜你喜欢

转载自www.cnblogs.com/z-lin/p/13388697.html