正文 435字数 441,773阅读


padding-bottom: constant(safe-area-inset-bottom); padding-bottom: env(safe-area-inset-bottom);
Run code
Cut to clipboard


    uni.getSysteminfo({ success: res => { let safeArea = res.safeAreaInsets.bottom; } })
    Run code
    Cut to clipboard


      该APi返回一个对象,包含 top right bottom left width height,其中bottom为安全区域高度

      对应的兼容情况如下,uni-app的版本2.5.3+使用safeAreaInsets值

      safeArea 在竖屏正方向下的安全区域 App、H5、微信小程序
      safeAreaInsets 在竖屏正方向下的安全区域插入位置(2.5.3+) App、H5、微信小程序