elementUI的Table表单分页记住选中状态

2,553 阅读1分钟

table表单在分页的时候,数据会重新加载,之前的选中状态会被清除,只能获取到当页的数据,想要在分页状态下记住上一页的选中值,需要设置几个属性

  1. el-table中绑定row-key属性
  2. el-table-column在type=“selection”的时候设置属性reserve-selection="true"
<el-table
    :row-key="getRowKeys"
    @selection-change="handleSelectionChange"
>
      <el-table-column
        type="selection"
        :reserve-selection="true"
        width="55"
      >
</el-table>


export default {
	data(){
    	getRowKeys(row) {
          return row.id;
        }
    },
    methods:{
    	handleSelectionChange(data){
        	console.log(data);
        }
    }
}