【解决】TypeError: this.$refs.treeRefs.xxx is not a function

2023-11-06

【问题】

使用refs触发子组件内方法时报:TypeError: this.$refs.treeRefs.xxx is not a function

【解决】

经查看,发现子组件被放在了v-for循环体内,示例代码如下:

<view v-for="(item,index) in list">
    <children ref="treeRefs"></children >
</view >
 

此时只需要加上下标 [0] 即可,示例代码如下:

this.$refs.treeRefs[0].xxx()

拒绝粗心大意!!!

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

【解决】TypeError: this.$refs.treeRefs.xxx is not a function 的相关文章

随机推荐