当前位置:网站首页>a-table中的rowSelection清空问题
a-table中的rowSelection清空问题
2022-07-26 09:21:00 【周小盗】
问题描述:
选中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: [],
}
computed中:
computed: {
rowSelection() {
return {
//onChange方法,rowSelection改变时触发
onChange: (selectedRowKeys, list) => {
//获取选中行的key元素,和下面selectedRowKeys属性配合使用,表示给rowSelection绑定一个v-model,为this.selectedRowKeys
this.selectedRowKeys=selectedRowKeys
//获取选中的行的所有元素
this.dataListSelectionList = list
},
selectedRowKeys:this.selectedRowKeys,
}
},
}
最后,要实现清空rowSelection选中状态,在methods的对应方法中写:
methods:{
clearRowSelection() {
//将选中行的所有元素置空
this.dataListSelectionList = []
//将选中行的keys置空(即清空选中状态)
this.selectedRowKeys=[]
}
}
边栏推荐
- [online problem] timeout waiting for connection from pool problem troubleshooting
- Selection and practice of distributed tracking system
- 【Mysql】redo log,undo log 和binlog详解(四)
- Grain College of all learning source code
- 【ARKit、RealityKit】把图片转为3D模型
- Laravel框架日志文件存放在哪里?怎么用?
- [use of final keyword]
- Li Mu D2L (IV) -- softmax regression
- redis原理和使用-安装和分布式配置
- I'm faded
猜你喜欢
随机推荐
csdn空格用什么表示
Error: Cannot find module ‘umi‘ 问题处理
Nuxt - Project packaging deployment and online to server process (SSR server rendering)
(2006,Mysql Server has gone away)问题处理
Li Mu D2L (V) -- multilayer perceptron
多层嵌套后的 Fragment 懒加载实现
Object type collections are de duplicated according to the value of an attribute
[online problem] timeout waiting for connection from pool problem troubleshooting
Study notes of dataX
分布式跟踪系统选型与实践
tornado之多进程服务
CF1481C Fence Painting
OnTap 9 file system limitations
jvm命令归纳
Bloom filter
Simple message mechanism of unity
Canal 的学习笔记
Tornado multi process service
MySQL strengthen knowledge points
滑动窗口、双指针、单调队列、单调栈







![[MySQL] detailed explanation of MySQL lock (III)](/img/3c/c6b5aa5693e6e7b5730a286d988c82.png)
