createSelectorQuery 获取元素距顶高度不准 有时候还报错

发布于 7 年前作者 jiesu629 次浏览最后编辑 7 年前来自 ask
// 获取评论节点信息
queryMultipleNodes: function() {
  var query = wx.createSelectorQuery();
  //选择id
  query.select('.comment-list-wrp').boundingClientRect()
  query.exec((res) => {
    //取高度
    this.setData({
      commentTop: res[0].top
    })
  })
},
 
 
        this.setData({
          comment: result.items,
          current_page: result._meta.currentPage,
          count_page: result._meta.pageCount,
        }, () => { setTimeout(() => { this.queryMultipleNodes()},1000)})

然后偶尔会有这样的问题 是什么问题呢

2 回复
pshi
pshi1 楼6 年前

提供一下能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

minyin
minyin2 楼5 年前

请问这个问题解决了吗