1)table添加
:row-key
@selection-change
2)多选列添加
:reserve-selection="true"
3)data中添加相关变量
4)method中添加相关方法
@selection-change="handleSelectionChange"
handleSelectionChange (ary) {
console.log(ary)
this.dataSure = ary
// this.multipleSelection = val
console.log('this.dataSure;;;;', this.dataSure)
this.select_order_number = this.dataSure.length
console.log('this.select_order_number;;;', this.select_order_number)
this.select_orderId = []
if (ary) {
ary.forEach(row => {
if (row) {
this.select_orderId.push(row.contNo)
}
})
}
}
实现效果,表格分页时,会保留每页的选中状态及将所有的选中数据放在一个数组中
5)清除数组
如果想清除数组,
table上需要添加refs
然后调用
clearSelection()