微信小程序如何获取页面高度再减去某个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';
    
    这个是获取页面高度再减去元素高度,怎么转化成微信小程序中使用呢?
阅读 7.9k
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

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题