您的位置:宽带测速网 > 网络知识 > 小程序如何获取页面高度

小程序如何获取页面高度

2025-06-17 10:29来源:互联网 [ ]

小程序获取页面高度的代码示例:

onReady:function(){

//动态获取高度

this.autoHeight();

},

//动态获取高度

autoHeight:function(){

varthat=this;

varquery=wx.createSelectorQuery();

query.select('.container').boundingClientRect(function(rect){

console.log("----w"+rect.height)

that.setData({

windowHeight:rect.height,//获取页面高度

})

}).exec();

},