微信小程序 设备


本文整理自网络,侵删。

微信小程序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
}

标签:微信小程序

相关阅读 >>

微信小程序 即时配送接口(商家查看)-附录 2:order_status枚举值

微信小程序api 画面录制器-创建webgl画面录制器

sdk数据库 command聚合操作符算数操作符

微信小程序api 视频-压缩接口

微信小程序云开发sdk文档 微信支付下载对账单

微信小程序 小程序使用addtip

微信小程序 图片智能裁剪能力

微信小程序表单组件 form

微信小程序api 接收消息和事件

微信小程序api 背景音频-监听停止时间

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




打赏

取消

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

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

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

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

评论

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