onLaunch: ()=> {
console.log('App Launch')
var ll = wx.getSystemInfo();
console.log(ll)
var lk = uni.getSystemInfo({
complete: (res)=> {
console.log(res)
}
})
var lj = uni.getSystemInfoSync()
console.log(lj)
setTimeout(function(){
var ll = wx.getSystemInfo();
console.log(ll)
var lk = uni.getSystemInfo({
complete: (res)=> {
console.log(res)
}
})
var lj = uni.getSystemInfoSync()
console.log(lj)
},1000)
},
![Itxiaoguang](https://img-cdn-tc.dcloud.net.cn/account/identicon/6440d386bb082b05e78d50a3a574a4ec.png)
- 发布:2020-08-01 16:38
- 更新:2020-11-07 16:06
- 阅读:1217
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: 10
HBuilderX类型: 正式
HBuilderX版本号: 2.8.2
手机系统: Android
手机系统版本号: Android 10
手机厂商: 小米
手机机型: 小米8
页面类型: vue
打包方式: 离线
项目创建方式: HBuilderX
示例代码:
操作步骤:
uni.getSystemInfoSync(),第一次安装 或者 热启动 得到的打印是异常的值
uni.getSystemInfoSync(),第一次安装 或者 热启动 得到的打印是异常的值
预期结果:
{
"errMsg": "getSystemInfo:ok",
"brand": "Xiaomi",
"model": "MI 8",
"pixelRatio": 2.75,
"screenWidth": 393,
"screenHeight": 817,
"windowWidth": 393,
"windowHeight": 767,
"statusBarHeight": 32,
"language": "zh-CN",
"system": "10",
"version": "1.9.9.80255",
"fontSizeSetting": "",
"platform": "android",
"SDKVersion": "",
"windowTop": 0,
"windowBottom": 0,
"safeArea": {
"left": 0,
"right": 393,
"top": 32,
"bottom": 767,
"width": 393,
"height": 735
},
"safeAreaInsets": {
"top": 32,
"right": 0,
"bottom": 0,
"left": 0
}
}
{
"errMsg": "getSystemInfo:ok",
"brand": "Xiaomi",
"model": "MI 8",
"pixelRatio": 2.75,
"screenWidth": 393,
"screenHeight": 817,
"windowWidth": 393,
"windowHeight": 767,
"statusBarHeight": 32,
"language": "zh-CN",
"system": "10",
"version": "1.9.9.80255",
"fontSizeSetting": "",
"platform": "android",
"SDKVersion": "",
"windowTop": 0,
"windowBottom": 0,
"safeArea": {
"left": 0,
"right": 393,
"top": 32,
"bottom": 767,
"width": 393,
"height": 735
},
"safeAreaInsets": {
"top": 32,
"right": 0,
"bottom": 0,
"left": 0
}
}
实际结果:
{
"errMsg": "getSystemInfo:ok",
"brand": "Xiaomi",
"model": "MI 8",
"pixelRatio": 2.880000114440918,
"screenWidth": 375,
"screenHeight": 781,
"windowWidth": 375,
"windowHeight": 731,
"statusBarHeight": 32,
"language": "zh-CN",
"system": "10",
"version": "1.9.9.80255",
"fontSizeSetting": "",
"platform": "android",
"SDKVersion": "",
"windowTop": 0,
"windowBottom": 0,
"safeArea": {
"left": 0,
"right": 375,
"top": 32,
"bottom": 731,
"width": 375,
"height": 699
},
"safeAreaInsets": {
"top": 32,
"right": 0,
"bottom": 0,
"left": 0
}
}
{
"errMsg": "getSystemInfo:ok",
"brand": "Xiaomi",
"model": "MI 8",
"pixelRatio": 2.880000114440918,
"screenWidth": 375,
"screenHeight": 781,
"windowWidth": 375,
"windowHeight": 731,
"statusBarHeight": 32,
"language": "zh-CN",
"system": "10",
"version": "1.9.9.80255",
"fontSizeSetting": "",
"platform": "android",
"SDKVersion": "",
"windowTop": 0,
"windowBottom": 0,
"safeArea": {
"left": 0,
"right": 375,
"top": 32,
"bottom": 731,
"width": 375,
"height": 699
},
"safeAreaInsets": {
"top": 32,
"right": 0,
"bottom": 0,
"left": 0
}
}
bug描述:
在APP.vue onLaunch 或者其他 xx.vue 里面调这个方法
var ll = wx.getSystemInfo();
console.log(ll)
var lk = uni.getSystemInfo({
complete: (res)=> {
console.log(res)
}
})
var lj = uni.getSystemInfoSync()
console.log(lj)
第一次安装 或者 热启动 得到的打印是(该打印是异常的值):
{
"errMsg": "getSystemInfo:ok",
"brand": "Xiaomi",
"model": "MI 8",
"pixelRatio": 2.880000114440918,
"screenWidth": 375,
"screenHeight": 781,
"windowWidth": 375,
"windowHeight": 731,
"statusBarHeight": 32,
"language": "zh-CN",
"system": "10",
"version": "1.9.9.80255",
"fontSizeSetting": "",
"platform": "android",
"SDKVersion": "",
"windowTop": 0,
"windowBottom": 0,
"safeArea": {
"left": 0,
"right": 375,
"top": 32,
"bottom": 731,
"width": 375,
"height": 699
},
"safeAreaInsets": {
"top": 32,
"right": 0,
"bottom": 0,
"left": 0
}
}
不是第一次安装且是冷启动打印是(该打印是正常的值):
{
"errMsg": "getSystemInfo:ok",
"brand": "Xiaomi",
"model": "MI 8",
"pixelRatio": 2.75,
"screenWidth": 393,
"screenHeight": 817,
"windowWidth": 393,
"windowHeight": 767,
"statusBarHeight": 32,
"language": "zh-CN",
"system": "10",
"version": "1.9.9.80255",
"fontSizeSetting": "",
"platform": "android",
"SDKVersion": "",
"windowTop": 0,
"windowBottom": 0,
"safeArea": {
"left": 0,
"right": 393,
"top": 32,
"bottom": 767,
"width": 393,
"height": 735
},
"safeAreaInsets": {
"top": 32,
"right": 0,
"bottom": 0,
"left": 0
}
}
异常值就会导致APP底部白屏,视频video跑偏
![](http://img-cdn-tc.dcloud.net.cn/uploads/questions/20200801/5b853f75c41b5a6f1e86b311fcbf3324.png)
![](http://img-cdn-tc.dcloud.net.cn/uploads/questions/20200801/bbe01f25abc5ed507713ae3312ec8614.png)