‘Cannot read property ‘changeSelect‘ of null’报错?

微信小程序获取子组件实例 let obj = this.selectComponent('#garden')
报错:‘Cannot read property 'changeSelect' of null’报错?

是因为:组件没有加载完成就调用
例如:组件引用放在wx:else或者wx:if里边了 ,去掉wx:if就可以了。或者邓组件完成在调用

猜你喜欢

转载自blog.csdn.net/men_gqi/article/details/114284707