问题描述:
选中a-table中的rowSelection之后,取消之前准备的操作,切换tab页,再次回来时rowSelection仍是选中状态。需要解决的就是:切换tab页回来时,清空rowSelection的选中状态。
解决代码:
html中:
<a-table :columns="column" :data-source="dataList" :rowKey="record => record.guid || record.stcd" :pagination="false" :row-selection="rowSelection" :scroll="{ x:1200,y:height}" bordered :loading="dataListLoading"/>
data中:
data() { column: columns[this.$parent.active][0], dataList: [], height:0, dataListLoading:false, //存放选中rows的数组 dataListSelectionList: [], selectedRowKeys: [], }
最后,要实现清空rowSelection选中状态,在methods的对应方法中写:
methods:{ clearRowSelection() { //将选中行的所有元素置空 this.dataListSelectionList = [] //将选中行的keys置空(即清空选中状态) this.selectedRowKeys=[] } }
原文链接:https://doubaoyuanma.com/blog/a-table%e4%b8%ad%e7%9a%84rowselection%e5%85%a8%e9%80%89%e5%a4%9a%e9%80%89%e9%97%ae%e9%a2%98,转载请注明出处。
评论0