收藏
回答

wx.getSystemInfoSync()有概率返回safeArea的top不对

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug wx.getSystemInfoSync() 微信安卓客户端 8.0.56 2.19.6

操作步骤如下:

1. 页面为横屏(通过<page-meta page-orientation="landscape">设置的)。

2. 在onLoad中设置成竖屏

3.onResize函数监听中调用wx.getSystemInfoSync(),有概率获取到的safeArea的top为0

下面为输出日志:

{"screenWidth": 367, "cpuType": "SM8550", "phoneCalendarAuthorized": true, "windowHeight": 814, "bluetoothEnabled": true, "bluetoothAuthorized": false, "language": "zh_CN", "microphoneAuthorized": true, "fontSizeScaleFactor": 1, "locationAuthorized": true, "notificationAuthorized": true, "model": "MAG-AN00", "statusBarHeight": 34, "safeArea": {"width": 367, "right": 367, "top": 0, "left": 0, "bottom": 814, "height": 814}, "brand": "HONOR", "windowWidth": 367, "locationEnabled": false, "benchmarkLevel": 31, "screenHeight": 814, "abi": "arm64-v8a", "version": "8.0.56", "cameraAuthorized": true, "deviceAbi": "arm64-v8a", "system": "Android 13", "memorySize": 15299, "fontSizeSetting": 16, "pixelRatio": 3.275, "deviceOrientation": "portrait", "wifiEnabled": true, "screenTop": 0, "platform": "android", "SDKVersion": "3.7.12", "enableDebug": true, "devicePixelRatio": 3.275, "host": {"env": "WeChat", "version": 671103070}, "mode": "default"}



回答关注问题邀请回答
收藏
登录 后发表内容