方案一
<view style="padding-bottom: {{safeBottom + 10}}px;"></view>
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 */