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中也调用过,也无法获取到
请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。
https://developers.weixin.qq.com/s/fSB184m6719b
提供的代码片段有误,请重新确认下
https://developers.weixin.qq.com/s/9O1yh6mk7L9p
建议先使用代码片段测试下,确保代码片段可复现问题再分享链接
index.wxml#L32 的 index 写错了,应该是 findex
https://developers.weixin.qq.com/miniprogram/dev/api/wxml/wx.createSelectorQuery.html
使用this还是获取不到