How does WeChat Mini Programs get the page height and subtract a certain view height

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";
    
    
Jul.27,2021

Mini Program provides it. You can refer to it to get the api, of the device.


let query = wepy.createSelectorQuery()
query.select('-sharplist').boundingClientRect()
query.selectViewport().scrollOffset()
query.exec((res) => {
  this.listHeight = res[0].height
  this.listTop = res[0].top
})

window height

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

image.png

image.png

Menu