微信小程序获取屏幕高度和宽度,并在视图层使用

逻辑层获取屏幕宽高:
 
//获取屏幕高度
this.setData({
height: wx.getSystemInfoSync().windowHeight,  //屏幕高度
width:wx.getSystemInfoSync().windowWidth  //屏幕宽度
})
 
视图层使用:
 
<view class="page" style="height:{{height}}px">
 
</view>

猜你喜欢

转载自www.cnblogs.com/P201721440036/p/11828327.html