$Native.getSystemInfoSync()

小于 1 分钟

$Native.getSystemInfoSync()

$Native.getSystemInfo 的同步版本

返回值

Object res

属性类型说明最低版本
brandstring设备品牌
modelstring设备型号
pixelRationumber设备像素比
screenWidthnumber屏幕宽度,单位 px
screenHeightnumber屏幕高度,单位 px
windowWidthnumber可使用窗口宽度,单位 px
windowHeightnumber可使用窗口高度,单位 px
statusBarHeightnumber状态栏的高度,单位 px (目前仅 Android)
languagestring设置的语言
versionstring版本号
systemstring操作系统及版本
platformstring客户端平台
fontSizeSettingnumber用户字体大小(单位 px)
SDKVersionstring客户端基础库版本
benchmarkLevelnumber设备性能等级(仅 Android 小游戏)。取值为:-2 或 0(该设备无法运行小游戏),-1(性能未知),>=1(设备性能值,该值越高,设备性能越好,目前最高不到 50)

示例代码

try {
  const res = $Native.getSystemInfoSync();
  console.log(res.model);
  console.log(res.pixelRatio);
  console.log(res.windowWidth);
  console.log(res.windowHeight);
  console.log(res.language);
  console.log(res.version);
  console.log(res.platform);
} catch (e) {
  // Do something when catch error
}