Linux 拨号vps windows公众号手机端

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

lewis 7年前 (2018-12-03) 阅读数 7 #VPS/云服务器
文章标签 小程序

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

实现代码如下:

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();

},

版权声明

本文仅代表作者观点,不代表米安网络立场。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

热门