ant-vue table换页以后选中的数据无法记住前一页已勾选的数据
解决方法:使用组件自带的onSelect事件和onSelectAll事件来记录
HTML:
Markup
<s-table
ref="table"
:columns="columns"
:data="loadData"
bordered
:alert="true"
:rowKey="(record) => record.id"
:rowSelection="{onSelect: onSelect,onSelectAll: onSelectAll,onChange: onSelectChange }"
>
</s-table>
method:
onSelect(record, selected) {
console.log("勾选",selected);
selected
? this.studentSelected0.push(record)
: this.studentSelected0.splice(
this.studentSelected0.findIndex(x => x.id === record.id),
1
)
},
onSelectAll(selected, selectedRows, changeRows) {
this.studentSelected0 = selected
? this.studentSelected0.concat(changeRows)
: this.studentSelected0.filter(x => !changeRows.find(i => i.id === x.id))
},
这样无论是否切换页面 this.studentSelected0 里面就是所有勾选的数据