小程序获取元素高度
针对有定位元素 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, }) })