uniapp 出现 Error in event handler for "service.requestComponentInfo" 错误的原因

2026-05-27 78 浏览 0 评论
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 里面就好了。


发布评论

发布评论前请先 登录
取消
0 评论
点赞
收藏

评论列表 0

暂无评论