注册

微信小程序API设备概览,微信小程序绑定设备

2017-12-22
导读:微信小程序API设备概览 系统信息——(wx.getSystemInfo、wx.getSystemInfoSync) 网络状态——(wx.getNetworkType) 重力感应——(wx.onAccelerometerChange) 罗 盘——(wx.onCompassChange) 拨打电话——...

微信小程序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
}
更多微信小程序开发教程,可以关注hi小程序。
重磅推荐:小程序开店目录

第一部分:小商店是什么

第二部分:如何开通一个小商店

第三部分:如何登录小商店

第四部分:开店任务常见问题

第五部分:小商店可以卖什么

第六部分:HiShop小程序特色功能

第七部分:小程序直播

第八部分:小程序收货/物流

第九部分:小程序怎么结算

第十部分:小程序客服

第十一部分:电商创业

第十二部分:小程序游戏开发