微信小程序 设备


本文整理自网络,侵删。

微信小程序API设备概览

  • 系统信息——(wx.getSystemInfo、wx.getSystemInfoSync)
  • 网络状态——(wx.getNetworkType)
  • 重力感应——(wx.onAccelerometerChange)
  • 罗 盘——(wx.onCompassChange)
  • 拨打电话——(wx.makePhoneCall)
  • 扫 码——(wx.scanCode)

wx.getSystemInfo(OBJECT)


获取系统信息。

OBJECT参数说明:

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

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
}

标签:微信小程序

相关阅读 >>

微信小程序云开发sdk文档 云函数

微信小程序 weui基础组件

微信小程序api 绘图createpattern

微信小程序 城市服务消息通路接口

微信小程序canvas中使用translate对坐标原点进行缩放

微信小程序云开发 调试

微信小程序云开发sdk文档 微信支付查询退款

微信小程序api 转发 (page.onshareappmessage)

微信小程序 即时配送接口(商家查看)-版本说明

sdk数据库 aggregate返回排序后结果

更多相关阅读请进入《微信小程序》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...