Skip to content

微信小程序——自动适配屏幕高度与宽度

微信小程序 | October 20, 2020


文章链接:https://blog.csdn.net/qq_43201350/article/details/109184903

wxml文件

<view class="page" style="height:{{windowHeight * 2}}rpx"></view>

js文件

data: {
windowHeight: 0
}
onLoad: function (options) {
	const that = this
			wx.getSystemInfo({
			success(res) {
				that.setData({
					windowHeight: res.windowHeight // 宽度为res.windowWidth
				})
			}
		})
}