小程序适配底部安全距离

 方案一

onLoad(options) {
    const { screenHeight, safeArea, windowHeight } = wx.getWindowInfo()
    let safeBottom = windowHeight
    if (safeArea?.bottom) {
      safeBottom = safeArea.bottom
    }
    safeBottom = screenHeight - safeBottom
    this.setData({
      safeBottom
    })
}

方案二(推荐)

padding-bottom: constant(safe-area-inset-bottom); /* 兼容iOS < 11.2 */  
padding-bottom: env(safe-area-inset-bottom); /* 兼容iOS > 11.2 */

你可能感兴趣的:(前端,小程序)