html52.com
我爱小程序-开发者交流社区

wx.getDeviceInfo 调用拿不到返回数据?

基础库2.28.1

官方文档上写的调用方式:

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)

实际打印出来的结果都是 undefined

将 deviceInfo 的结果打印出来,发现是个 Promise。

将 deviceInfo 的结果打印出来,发现是个 Promise。所以尝试使用 Promise 的写法来进行调用:

所以尝试使用 Promise 的写法来进行调用:

wx.getDeviceInfo().then(res => {
    console.log('the wx.getDeviceInfo is:', res) // 实际这行代码不会执行,也就是同样拿不到结果
})

网友回复

社区技术运营专员-Jahozheng:

社区技术运营专员-Jahozheng:Jianbo:换 getSystemInfo 试试

Jianbo:
换 getSystemInfo 试试

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付