收藏
回答

createSelectorQuery获取不到节点

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug createSelectorQuery 客户端 7.04 2.7.1


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中也调用过,也无法获取到

回答关注问题邀请回答
收藏

3 个回答

登录 后发表内容