微信小程序如何获取页面高度再减去某个view高度

var bodyHeight = document.documentElement.clientHeight;

    var oCardbox = document.getElementById('cardbox');
    var oCardfoot = document.getElementById('cardfoot');
    var oCfheight = oCardfoot.clientHeight;

    oCardbox.style.height = bodyHeight - oCfheight + 'px';
    
    这个是获取页面高度再减去元素高度,怎么转化成微信小程序中使用呢?
阅读 8k
3 个回答
let query = wepy.createSelectorQuery()
query.select('#list').boundingClientRect()
query.selectViewport().scrollOffset()
query.exec((res) => {
  this.listHeight = res[0].height
  this.listTop = res[0].top
})

窗口高度

wx.getSystemInfo({
 success: function (res) {
   console.log(res.windowHeight)
 }
})

小程序提供了,获取设备的api,可以去参考一下。

image.png

image.png

推荐问题