小程序wx.getDeviceInfo
Object wx.getDeviceInfo()
获取设备基础信息
基础库 2.20.1 开始支持,低版本需做兼容处理。
小程序插件:支持,需要小程序基础库版本不低于 2.21.3
返回值
Object
属性 类型 说明
abi string 应用二进制接口类型(仅 Android 支持)
benchmarkLevel number 设备性能等级(仅 Android 支持)。取值为:-2 或 0(该设备无法运行小游戏),-1(性能未知),>=1(设备性能值,该值越高,设备性能越好,目前最高不到50)
brand string 设备品牌
model string 设备型号。新机型刚推出一段时间会显示unknown,微信会尽快进行适配。
system string 操作系统及版本
platform string 客户端平台
示例代码
const deviceInfo = wx.getDeviceInfo()
console.log(deviceInfo.abi)
console.log(deviceInfo.benchmarkLevel)
console.log(deviceInfo.brand)
console.log(deviceInfo.model)
console.log(deviceInfo.platform)
console.log(deviceInfo.system)
- 小程序wx.getSystemInfo
- 获取系统信息。由于历史原因,wx.getSystemInfo 是异步的调用格式,但是是同步返回,需要异步获取系统信息请使用 wx.getSystemInfoAsy
- 04-02 关注:0