课程表

微信小程序框架

微信小程序组件

微信小程序API

微信小程序开放接口

微信小程序工具

微信小程序设计规范

工具箱
速查手册

小程序API 系统信息

当前位置:免费教程 » 移动开发 » 微信小程序

wx.getSystemInfo(OBJECT)

获取系统信息。

OBJECT参数说明:

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

success回调参数说明:

参数说明
model手机型号
pixelRatio设备像素比
screenWidth屏幕宽度
screenHeight屏幕高度
windowWidth可使用窗口宽度
windowHeight可使用窗口高度
language微信设置的语言
version微信版本号
system操作系统版本
platform客户端平台
SDKVersion客户端基础库版本

screenWidth, screenHeight, SDKVersion 基础库版本 1.1.0 开始支持,低版本需做兼容处理

screenWidth, screenHeight, SDKVersion 微信客户端 6.5.6 版本开始支持

示例代码:

  1. wx.getSystemInfo({
  2. success: function(res) {
  3. console.log(res.model)
  4. console.log(res.pixelRatio)
  5. console.log(res.windowWidth)
  6. console.log(res.windowHeight)
  7. console.log(res.language)
  8. console.log(res.version)
  9. console.log(res.platform)
  10. }})

wx.getSystemInfoSync()

获取系统信息同步接口

示例代码:

  1. try {
  2. var res = wx.getSystemInfoSync()
  3. console.log(res.model)
  4. console.log(res.pixelRatio)
  5. console.log(res.windowWidth)
  6. console.log(res.windowHeight)
  7. console.log(res.language)
  8. console.log(res.version)
  9. console.log(res.platform)
  10. } catch (e) {
  11. // Do something when catch error
  12. }
转载本站内容时,请务必注明来自W3xue,违者必究。
 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号