element的el-table 解决表格多页选择数据时,数据被清空
【代码】element的el-table 解决表格多页选择数据时,数据被清空。
·
问题:切换页码时,勾选的数据会被清空
重点看我圈出来的,直接复制,注意,我这里 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;
},
}

DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。
更多推荐
所有评论(0)