createSelectorQuery获取不到节点
发布于 6 年前 作者 li26 14610 次浏览 来自 问答

infoScroll: function() {

var that = this;

var len = that.data.productList.length;

that.setData({

navH: app.globalData.navHeight,

// number: that.data.productList[len - 1].child.length

})

//设置商品列表高度

wx.getSystemInfo({

success: function(res) {

that.setData({

height: (res.windowHeight) * (750 / res.windowWidth) - 98 - app.globalData.navHeight

//res.windowHeight:获取整个窗口高度为px,*2为rpx;98为头部占据的高度;

})

},

});

var height = 0;

var hightArr = [];

for (var i = 0; i < len; i++) { //productList

var query = wx.createSelectorQuery();

var idView = “#b” + i;

query.select(idView).boundingClientRect();

query.selectViewport().scrollOffset()

query.exec(function (res) {

console.log(res);

var top = res[0].top;

hightArr.push(top);

that.setData({

hightArr: hightArr

});

});

};

},

定时器使用过也无法获取到节点,在onready中也调用过,也无法获取到

1 回复

请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

回到顶部