针对有定位元素
var query = wx.createSelectorQuery();
var scrollLeft = that.data.scrollLeft
query.select(’.stitTop’).boundingClientRect()
query.select(’.time’).boundingClientRect()
query.select(’.info’).boundingClientRect()
var myTime = setTimeout(function () {
query.exec((res) => {
console.log(res[0].height)
console.log(res[1].height)
console.log(res[2].height)
var shopListHeight = wx.getSystemInfoSync().windowHeight - (res[0].height + 15) - res[1].height - 54
var shopAdsTrue = shopListHeight - 110
console.log(shopListHeight)
that.setData({
scrollLeft: shopListHeight,
scrolllist: shopAdsTrue,
})
})
clearTimeout(myTime)
}, 1000)
(用定时器)
无定位
var query = wx.createSelectorQuery();
var scrollLeft = that.data.scrollLeft
query.select(’.stitTop’).boundingClientRect()
query.select(’.time’).boundingClientRect()
query.select(’.info’).boundingClientRect()
query.exec((res) => {
console.log(res[0].height)
console.log(res[1].height)
console.log(res[2].height)
var shopListHeight = wx.getSystemInfoSync().windowHeight - (res[0].height + 15) - res[1].height - 54
var shopAdsTrue = shopListHeight - 110
console.log(shopListHeight)
that.setData({
scrollLeft: shopListHeight,
scrolllist: shopAdsTrue,
})
})
来源:CSDN
作者:FuturePeriod
链接:https://blog.csdn.net/weixin_45244453/article/details/103876893