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

使用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)
未经允许不得转载:好便宜VPS » 如何动态获取小程序页面的高度
分享到: 更多 (0)