uniapp 出现 Error in event handler for "service.requestComponentInfo" 错误的原因
getElmSize(el, inCom = false, obj = null) {
return new Promise(r => {
const query = inCom ? wx.createSelectorQuery().in(obj) : wx.createSelectorQuery();
query.select(el).boundingClientRect();
query.selectViewport().scrollOffset();
query.exec(function (res) {
r(res);
});
});
},
在 onLoad 里面用了 uni.createSelectorQuery() 查找要元素,导致找不到 handCenter 节点,因为元素还没有渲染出来,就开始查找元素,肯定会报错的。解决方案:在外面套一层 this.$nextTick(),或者放在 onReady 里面就好了。