onReady(() => {
// 高度相关信息需在 onReady 中获取,太早取不到
windowInfo.value = JSON.stringify(uni.getWindowInfo());
systemInfo.value = JSON.stringify(uni.getSystemInfoSync());
// #ifdef APP-PLUS
try {
const statusBarHeight = plus.navigator.getStatusbarHeight();
plusStatusbarHeight.value = JSON.stringify({ raw: statusBarHeight, scale: plus.screen.scale, scaled: statusBarHeight * plus.screen.scale });
} catch (e) {
plusStatusbarHeight.value = '获取失败:' + e.message;
}
// #endif
});
- 发布:59 分钟前
- 更新:57 分钟前
- 阅读:39
产品分类: uni小程序SDK
手机系统: iOS
手机系统版本号: iOS 16
手机厂商: 苹果
手机机型: iPhone 16 Pro Max
页面类型: vue
SDK版本号: 5.26
示例代码:
操作步骤:
应该在iPhone 16 Pro Max中打印日志就能看到,我是打包成uni小程序SDK在ios查看的日志
应该在iPhone 16 Pro Max中打印日志就能看到,我是打包成uni小程序SDK在ios查看的日志
预期结果:
状态栏"statusBarHeight":0不应该为0
状态栏"statusBarHeight":0不应该为0
实际结果:
状态栏"statusBarHeight":0
状态栏"statusBarHeight":0
bug描述:
在onReady函数中uni.getWindowInfo()获取到状态栏"statusBarHeight":0的"pixelRatio":3,"screenWidth":440,"screenHeight":956,"windowWidth":440,"windowHeight":912,"statusBarHeight":0,"safeArea":{"left":0,"right":440,"top":0,"bottom":912,"width":440,"height":912},"safeAreaInsets":{"top":0,"right":0,"bottom":0,"left":0},"windowTop":0,"windowBottom":0,"screenTop":44},
下边是uni.getSystemInfoSync()设备信息:
SDKVersion":"","appId":"UNI891C149","appLanguage":"zh-Hans","appName":"公募基金产品","appVersion":"1.2.49","appVersionCode":"1249","appWgtVersion":"1.2.49","brand":"apple","browserName":"wkwebview","browserVersion":"27.0","deviceBrand":"apple","deviceId":"BD0FFE2EC676813511A1543D8DE47002","deviceModel":"iPhone 16 Pro Max","deviceOrientation":"portrait","devicePixelRatio":3,"deviceType":"phone","hostLanguage":"zh-Hans-CN","hostName":"","hostPackageName":"net.nanhua.qh","hostTheme":"light","hostVersion":"7.3.9","isUniAppX":false,"language":"zh-Hans-CN","model":"iPhone 16 Pro Max","osLanguage":"zh-Hans-CN","osName":"ios","osTheme":"light","osVersion":"27.0","pixelRatio":3,"platform":"ios","safeArea":{"left":0,"right":440,"top":0,"bottom":912,"width":440,"height":912},"safeAreaInsets":{"top":0,"right":0,"bottom":0,"left":0},"screenHeight":956,"screenWidth":440,"statusBarHeight":0,"system":"iOS 27.0","ua":"Mozilla/5.0 (iPhone; CPU iPhone OS 18_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 Html5Plus/1.0 (Immersed/62) uni-app","uniCompileVersion":"5.26","uniCompilerVersion":"5.26","uniPlatform":"app","uniRuntimeVersion":"4.75","version":"1.9.9.81590","windowBottom":0,"windowHeight":912,"windowTop":0,"windowWidth":440}
我使用 plus.navigator.getStatusbarHeight();获取到状态栏为62,{"raw":62,"scale":3,"scaled":186}
1 个回复
Ask小助手 - Ask社区AI助手
您好,感谢您提交的 bug 反馈。以下以官方视角对本反馈进行评审:
一、反馈完整性评审
做得较好的部分:
uni.getWindowInfo()与uni.getSystemInfoSync()的返回 JSON,并额外提供了plus.navigator.getStatusbarHeight()的对照数据(raw 62 / scaled 186),这对定位问题非常有价值;需要补充/确认的部分:
二、bug 成立性分析
uni.getWindowInfo()的 statusBarHeight 应返回“手机状态栏的高度”(详见)。您已排除取值时机问题,且 plus 层(plus.navigator.getStatusbarHeight 返回 62)与 uni 层(statusBarHeight: 0、safeAreaInsets.top: 0)数据不一致,现象确实异常,不属于明显误报,具备排查价值。三、临时替代方案
在问题解决前,App 端(含 uni小程序SDK 场景)可使用
plus.navigator.getStatusbarHeight()获取状态栏高度(您已验证可用,返回值为逻辑像素,乘以plus.screen.scale为物理像素)。另外文档说明 CSS 变量var(--status-bar-height)在 App 里为手机实际状态栏高度(详见),是否受当前场景影响需您实测确认。而基于 statusBarHeight/safeArea 计算顶部安全区留白的通用方案,在 statusBarHeight 为 0 时无法直接生效,需先解决取值问题。四、评审结论
本反馈质量较高、现象明确(plus 层 62 与 uni 层 0 形成有效对照),预期结果合理,不属于误报;但运行环境信息(uni小程序SDK 版本、宿主窗口配置、实际系统版本)需补充,复现步骤需细化。建议先升级宿主 app 的 uni小程序SDK 运行时复测,并重点排查宿主窗口布局对 screenTop/statusBarHeight 的影响。
要回复问题请先登录或注册
公告
更多>相关问题