hoey
hoey
  • 发布:2018-12-07 20:06
  • 更新:2020-03-09 10:00
  • 阅读:8540

API 兼容问题: uni.getSystemInfoSync, uni.getSystemInfo

分类:uni-app

H5 所有IOS手机Safari浏览器:
调用uni.getSystemInfoSync() 输出异常为 TypeError: undefined is not an object (evaluating 'd.$children[0]')
虽然uni.getSystemInfo()没有异常,但是获取不到系统信息

2018-12-07 20:06 负责人:无 分享
已邀请:
DCloud_UNI_GSQ

DCloud_UNI_GSQ

测试未发现问题
提供一下出问题的几个设备的机型和系统版本信息

API 返回 Promise 方式的数据格式为:

[null,{"authResult":{"scope":"scope","access_token":"access_token","openid":"openid"},"errMsg":"login: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

hoey

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

hoey (作者)

HbuilderX 版本是 1.3.1.20181211

hoey

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"}]

蹦豆儿

蹦豆儿

荣耀20,高度只有机子高度的一半

  • w***@163.com

    回复 DCloud_UNI_GSQ: 您好,我也遇到这个问题了,是锤子浏览器,获取windowHeight只有不到一半的高度

    2020-03-20 16:38

  • DCloud_UNI_GSQ

    回复 w***@163.com: 更新HBuilderX alpha 2.6.6后重新编译

    2020-03-20 19:04

  • 蹦豆儿

    回复 w***@163.com: 我没有更新,我怕更新后会带来其它问题。所以改变布局了

    2020-03-26 17:32

该问题目前已经被锁定, 无法添加新回复