const {
safeAreaInsets
} = uni.getSystemInfoSync()
// iphone 品牌机型 正常返回
{
"top": 47,
"left": 0,
"right": 0,
"bottom": 34
}
// 安卓机型 结果返回异常
{
"top": 0,
"left": 0,
"right": 0,
"bottom": 2340
}
![w***@163.com](https://img-cdn-tc.dcloud.net.cn/account/identicon/53a3aa8295d09ce028fe69936a17def9.png)
- 发布:2024-07-02 16:40
- 更新:2024-07-30 16:28
- 阅读:59
产品分类: uniapp/小程序/阿里
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: 22631.3737
HBuilderX类型: 正式
HBuilderX版本号: 4.15
第三方开发者工具版本号: 3.8.21
基础库版本号: 2.9.12
项目创建方式: HBuilderX
示例代码:
操作步骤:
const {
safeAreaInsets
} = uni.getSystemInfoSync()
// iphone 品牌机型 正常返回
{
"top": 47,
"left": 0,
"right": 0,
"bottom": 34
}
// 安卓机型 结果返回异常
{
"top": 0,
"left": 0,
"right": 0,
"bottom": 2340
}
const {
safeAreaInsets
} = uni.getSystemInfoSync()
// iphone 品牌机型 正常返回
{
"top": 47,
"left": 0,
"right": 0,
"bottom": 34
}
// 安卓机型 结果返回异常
{
"top": 0,
"left": 0,
"right": 0,
"bottom": 2340
}
预期结果:
{
"top": 47,
"left": 0,
"right": 0,
"bottom": 34
}
{
"top": 47,
"left": 0,
"right": 0,
"bottom": 34
}
实际结果:
{
"top": 0,
"left": 0,
"right": 0,
"bottom": 2340
}
{
"top": 0,
"left": 0,
"right": 0,
"bottom": 2340
}
bug描述:
1、问题描述:运行支付宝小程序开发者工具,除iphone品牌以外的安卓机型返回异常,详情看下方代码
const {
safeAreaInsets
} = uni.getSystemInfoSync()
// iphone 品牌机型 正常返回
{
"top": 47,
"left": 0,
"right": 0,
"bottom": 34
}
// 安卓机型 结果返回异常
{
"top": 0,
"left": 0,
"right": 0,
"bottom": 2340
}
1 个回复
DCloud_UNI_OttoJi - 日常回复 uni-app/x 问题,如果艾特我没看到,请主动私信
感谢反馈,你提到安卓获取uni. getSystemInfoSync 里的 safeArea 异常。经过我测试,这个 api 在支付宝小程序相当于调用
my.getSystemInfoSync
,根据对应文档 提示https://opendocs.alipay.com/mini-game/08v96p
返回值 safeArea 在竖屏正方向下的安全区域。安卓暂不支持。供你参考