由于分页多选时状态不能保留,用element-ui提供的简单方法
<el-table
ref="table"
v-loading="crud.loading"
:header-cell-style="{ color: '#FFF', background: '#333' }"
:cell-style="{ color: '#FFF', background: '#333' }"
:data="crud.data"
style="width: 100%"
:row-key="getRowKey"
:default-sort="{ prop: 'barcode', order: 'descending' }"
@selection-change="crud.selectionChangeHandler"
>
<el-table-column type="selection" width="55" :reserve-selection="true" />
在method中添加这个方法:
getRowKey(row) {
return row.id;
},
table中的多选框,点击下一页时,需要记住上一页的数据,因此需要添加
:row-key=“getRowKeys”
:reserve-selection=“true”
getRowKeys(row) {
return row.id
},
在完成后,需要清空选中的
this.$refs.table.clearSelection()