小程序獲取頁面高度的代碼示例:
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();
},