H5 所有IOS手机Safari浏览器:
调用uni.getSystemInfoSync() 输出异常为 TypeError: undefined is not an object (evaluating 'd.$children[0]')
虽然uni.getSystemInfo()没有异常,但是获取不到系统信息
- 发布:2018-12-07 20:06
- 更新:2020-03-09 10:00
- 阅读:8942
测试未发现问题
提供一下出问题的几个设备的机型和系统版本信息
API 返回 Promise 方式的数据格式为:
[null,{"authResult":{"scope":"scope","access_token":"access_token","openid":"openid"},"errMsg":"login:ok"}]
这个文档中后续会补充说明
hoey (作者)
let defaultLang = uni.getStorageSync('lang');
if(!defaultLang){
try{
defaultLang = uni.getSystemInfoSync().language.replace(/-/g, "_");
}catch(e){
alert(JSON.stringify(e))
//alert:{"line":928, column:13702, "sourceURL":"http://192.168.1.231:8080/index.js"}
uni.getSystemInfo().then(function(e){
alert(JSON.stringify(e))
//alert:{"line":928, column:13702, "sourceURL":"http://192.168.1.231:8080/index.js"}
})
}
}
就是以上代码出问题的,H5 所有IOS手机Safari浏览器都不行,试了还几个机子,5s,6s,7plus都不行。这个代码是写在main.js的,难道是没有初始化完获取不到?不科学啊
hoey (作者)
Android机下的 alert结果是
[null,{"windowTop":0,"windowBottom":50,"windowWidth":375,"windowHeight":617,"pixelRatio":2,"screenWidth":375,"screenHeight":667,"language":"zh-CN","statusbarHeight":0,"system":"iOS 11.0","platform":"ios","model":"iPhone","errMsg":"getSystemInfo:ok"}]
hoey (作者)
uni.getSystemInfoSync() 这个api在main.js调用有问题。其他vue页面可以正常调用
2018-12-12 17:25
DCloud_UNI_GSQ
回复 hoey:即使写在main。js里建议在app初始化之后再调用
2018-12-12 19:12
hoey (作者)
回复 DCloud_UNI_GSQ: 嗯,只能先这样用了
2018-12-13 14:37
喜欢技术的前端
uni.getSystemInfo() screenHeight这个参数数值只有不到一半的高度,红米4A上,麻烦看一下
2019-01-23 09:57
DCloud_UNI_GSQ
@18729226704@163.com:windowHeight呢?
2019-01-23 13:13
蹦豆儿
回复 DCloud_UNI_GSQ: HONOR 20, 型号:YAL-AL00 Android版本 10这个高试获取的是机子的一半
2020-03-09 10:06
蹦豆儿
回复 DCloud_UNI_GSQ: 得出的手机高度是339
2020-03-09 10:09
mfan
回复 DCloud_UNI_GSQ: uni.getSystemInfo 获取的windowHeight,windowTop高度不正确 {"windowTop":440,"windowBottom":0,"windowWidth":375,"windowHeight":227,"pixelRatio":2,"screenWidth":375,"screenHeight":667,"language":"zh-CN","statusBarHeight":0,"system":"iOS 10.3","platform":"ios","model":"iPhone","safeArea":{"left":0,"right":375,"top":0,"bottom":667,"width":375,"height":667},"safeAreaInsets":{"top":0,"right":0,"bottom":0,"left":0},"errMsg":"getSystemInfo:ok"}
2020-03-10 09:08