Taro.getDeviceInfo()

获取设备基础信息

支持情况:Taro.getDeviceInfo() 获取设备信息 - 图1 Taro.getDeviceInfo() 获取设备信息 - 图2 Taro.getDeviceInfo() 获取设备信息 - 图3

H5: 不支持 abi、benchmarkLevel

参考文档

类型

  1. () => Result

参数

Result

参数 类型 必填 说明
abi string 应用二进制接口类型(仅 Android 支持)
benchmarkLevel number 设备性能等级(仅Android小游戏)。取值为:-2 或 0(该设备无法运行小游戏),-1(性能未知),>=1(设备性能值,该值越高,设备性能越好,目前最高不到50)
brand string 设备品牌
model string 设备型号
system string 操作系统及版本
platform string 客户端平台

示例代码

  1. const deviceInfo = Taro.getDeviceInfo()
  2. console.log(deviceInfo.abi)
  3. console.log(deviceInfo.benchmarkLevel)
  4. console.log(deviceInfo.brand)
  5. console.log(deviceInfo.model)
  6. console.log(deviceInfo.platform)
  7. console.log(deviceInfo.system)