vue在父组件如何获取子组件的ref

步骤:1.给父组件定义一个ref
2.子组件也是一样的ref

父组件
<div>
  <subpage ref="table"></subpage>
</div>

子组件
<div ref="subTable">
</div>
//在控制台 可以看到很多属性,本质就是一个字符串 
console.log(this.$refs.table)

//这样就获取到了
console.log(this.$refs.table.$refs.table)

猜你喜欢

转载自blog.csdn.net/weixin_42821697/article/details/119670229#comments_20785359