wx.createSelectorQuery()拿到的值为空
通过wx.createSelectorQuery().in(that)获取不到节点,必须通过定时器来获取(setTimeout在onLoad里面写)
setTimeout(function(){
let heightArr = [];
let s = 0;
wx.createSelectorQuery().in(that).selectAll(’.mink’).boundingClientRect((react)=> {
console.log(react)
react.forEach(function (res) {
console.log(res)
s += res.height;
heightArr.push(s)
console.log(heightArr)
})
that.setData({
heightArr: heightArr
})
}).exec()
wx.createSelectorQuery().in(that).selectAll(’.market-scroll-list’).boundingClientRect((res) => {
// 计算容器高度
console.log(res[0])
console.log(res[0].height)
that.setData({
containerH: res[0].height
})
}).exec()
},500)
wx.createSelectorQuery()拿到的值为空
最新推荐文章于 2025-04-16 12:39:12 发布