ElementUI中 table关于this.$refs 的多重变化

今天在使用elementUi中发现一个神奇的现象
当使用tabled的时候
使用一个table
<el-table ref="table"></el-table>
此时 尝试去打印 this.$refs.table 可以发现

clipboard.png
此时比如我们嗲用 this.$refs.table.clearSelection()是可以调用的
但是当我们有多个table

<el-table ref="table1"></el-table>
<el-table ref="table2"></el-table>

打印 this.$refs.table1 this.$refs.table2 是这样的

clipboard.png
此时我们调用 this.$refs.table1.clearSelection()
this.$refs.table2.clearSelection()是报错的
调用方式变为 this.$refs.table1[0].clearSelection()
this.$refs.table2[0].clearSelection()
我想问一下大佬们 为什么在多个table存在的时候 会产生这样的变化 this.$refs.table会由对象变化为数组对象

阅读 6.9k
1 个回答

当在v-for里面的时候,会变成数组

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题