vue中父组件调用子组件的方法都有哪些?他们在性能上有区别吗?或者建议通过什么方式去获取子组件的方法

最近在一个群里有个小伙伴说 在react中不建议通过ref的形式去获取子组件的一些方法,这种方式在性能上消耗较大,所以我就想在vue中通过这方式是否会有这样的顾虑?

阅读 1.6k
1 个回答

使用callback ref代替string ref

eg:

// string ref
<ComponentA ref="componentA"/>
// callback ref
<ComponentA ref="(com) => { this.componentA = com }"/>
推荐问题