小程序

如何动态获取小程序页面的高度

九三
376
2020-12-11 15:00:08
栏目: 云计算

如何动态获取小程序页面的高度

使用onReady事件动态获取小程序页面的高度

实现代码如下:

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
看了该问题的人还看了