温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

微信小程序API设备怎么绑定

发布时间:2022-03-07 14:48:52 来源:亿速云 阅读:176 作者:iii 栏目:开发技术

这篇文章主要介绍了微信小程序API设备怎么绑定的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇微信小程序API设备怎么绑定文章都会有所收获,下面我们一起来看看吧。

微信小程序API设备概览


  • 系统信息——(wx.getSystemInfo、wx.getSystemInfoSync)

  • 网络状态——(wx.getNetworkType)

  • 重力感应——(wx.onAccelerometerChange)

  • 罗 盘——(wx.onCompassChange)

  • 拨打电话——(wx.makePhoneCall)

  • 扫 码——(wx.scanCode)

wx.getSystemInfo(OBJECT)


获取系统信息。

OBJECT参数说明:

参数 类型 必填 说明
success Function 接口调用成功的回调
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

success回调参数说明:

属性 说明
model 手机型号
pixelRatio 设备像素比
windowWidth 窗口宽度
windowHeight 窗口高度
language 微信设置的语言
version 微信版本号
system 操作系统版本
platform 客户端平台

示例代码:

wx.getSystemInfo({
  success: function(res) {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)
  }
})

wx.getSystemInfoSync()


获取系统信息同步接口

示例代码:

try {  var res = wx.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}

关于“微信小程序API设备怎么绑定”这篇文章的内容就介绍到这里,感谢各位的阅读!相信大家对“微信小程序API设备怎么绑定”知识都有一定的了解,大家如果还想学习更多知识,欢迎关注亿速云行业资讯频道。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI