zhijie1
由于小程序的宽度是固定的 750rpx,我们可以先用 wx.getSystemInfo 来获取可使用窗口的宽高(并非rpx),结合750rpx的宽度算出比例,再用比例来算出高度
let that = this; // 获取系统信息 wx.getSystemInfo({ success: function (res) { // 获取可使用窗口宽度 let clientHeight = res.windowHeight; // 获取可使用窗口高度 let clientWidth = res.windowWidth; // 算出比例 let ratio = 750 / clientWidth; // 算出高度(单位rpx) let height = clientHeight * ratio; // 设置高度 that.setData({ height: height }); } });

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-02-07
  • 2021-12-29
  • 2022-01-07
猜你喜欢
  • 2022-01-07
  • 2022-01-08
  • 2022-12-23
  • 2021-11-18
  • 2022-01-07
  • 2022-01-07
  • 2022-01-08
相关资源
相似解决方案