小程序 小程序页面

小程序如何获取页面高度

小新
975
2021-03-19 18:03:30
栏目: 云计算

小程序如何获取页面高度

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

onReady: function () {

//动态获取高度

this.autoHeight();

},

//动态获取高度

autoHeight:function(){

var that = this;

var query = wx.createSelectorQuery();

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

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

that.setData({

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

})

}).exec();

},


0
看了该问题的人还看了