问题:切换页码时,勾选的数据会被清空
重点看我圈出来的,直接复制,注意,我这里 return row.productId;一般大家的是 return row.id,根据接口定的唯一变量
:row-key="getRowKeys"
:reserve-selection="true"
getRowKeys(row) {
return row.productId;
},
官方解说
参考我项目里的下方代码
<el-table v-loading="listLoading"
:data="list"
ref="multipleTable"
border
fit
@selection-change="handleSelectionChange"
:row-key="getRowKeys"
highlight-current-row>
<el-table-column
:reserve-selection="true"
type="selection"
width="40">
</el-table-column>
<el-table-column align="center"
width="180px"
label="销售单号">
<template slot-scope="scope">
<span>{{ scope.row.orderId }}</span>
</template>
</el-table-column>
</el-table>
data () {
return {
getRowKeys(row) {
return row.productId;
},
rowSelection:'',
}
methods: {
handleSelectionChange(val) {
this.rowSelection = val;
},
}