给小程序页面设置背景颜色,动态设置页面的高度为一屏高度
data: {
height: 0,
}
/**
- 生命周期函数–监听页面初次渲染完成
- */
onReady: function () {
let that = this;
wx.getSystemInfo({
success: function (res) {
let clientHeight = res.windowHeight;
let clientWidth = res.windowWidth;
let ratio = 750 / clientWidth;
let height = clientHeight * ratio;
that.setData({
height:${height}rpx
});
}
});
},