网站首页 > 精选文章 正文
当我们需要清空 el-table 的选中记录时,需要用到内置 clearSelection 函数,而他的用法需要分两种情况来说。一种是执行 clearSelection 这个操作的代码与 el-table 在同一 vue 文件中,另一种则是不在同一文件中,也就是 el-table 被封装在子组件中,供父组件调用。
情况一:el-table 在当前 vue 文件中
此时直接调用 el-table 的 clearSelection 函数即可:
this.$refs.myTable.clearSelection()
注:myTable 是 el-table 的 ref 名称
情况二:el-table 在 子组件中
此时有两种方法可用:
方法一:
this.$refs.tableComponent.$refs.commonTable.clearSelection()
方法二:
this.$refs.tableComponent.$children[0].clearSelection()
注:tableComponent 是子组件的 ref 名称,commonTable 是 el-table 的 ref 名称。
猜你喜欢
- 2025-04-05 vue中通过v-on、v-bind来更方便向'孙子'组件传数据和方法
- 2025-04-05 从零开始学Vue!详解v-text、v-html、v-on、v-show、v-if
- 2025-04-05 Vue通信揭秘:深入理解$emit与$on的真谛
- 最近发表
- 标签列表
-
- 向日葵无法连接服务器 (32)
- git.exe (33)
- vscode更新 (34)
- dev c (33)
- git ignore命令 (32)
- gitlab提交代码步骤 (37)
- java update (36)
- vue debug (34)
- vue blur (32)
- vscode导入vue项目 (33)
- vue chart (32)
- vue cms (32)
- 大雅数据库 (34)
- 技术迭代 (37)
- 同一局域网 (33)
- github拒绝连接 (33)
- vscode php插件 (32)
- vue注释快捷键 (32)
- linux ssr (33)
- 微端服务器 (35)
- 导航猫 (32)
- 获取当前时间年月日 (33)
- stp软件 (33)
- http下载文件 (33)
- linux bt下载 (33)