微信小程序API系统信息,wx.getSystemInfo获取系统信息
本文摘要
wx.getSystemInfo(OBJECT) 获取系统信息。 OB
wx.getSystemInfo(OBJECT)
获取系统信息。
OBJECT参数说明:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| success | Function | 是 | 接口调用成功的回调 |
| fail | Function | 否 | 接口调用失败的回调函数 |
| complete | Function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
success回调参数说明:
| 参数 | 说明 | 最低版本 |
|---|---|---|
| model | 手机型号 | |
| pixelRatio | 设备像素比 | |
| screenWidth | 屏幕宽度 | 1.1.0 |
| screenHeight | 屏幕高度 | 1.1.0 |
| windowWidth | 可使用窗口宽度 | |
| windowHeight | 可使用窗口高度 | |
| language | 微信设置的语言 | |
| version | 微信版本号 | |
| system | 操作系统版本 | |
| platform | 客户端平台 | |
| fontSizeSetting | 用户字体大小设置。以“我-设置-通用-字体大小”中的设置为准,单位:px | 1.5.0 |
| SDKVersion | 客户端基础库版本 | 1.1.0 |
示例代码:
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()
获取系统信息同步接口
同步返回参数说明:
| 参数 | 说明 | 最低版本 |
|---|---|---|
| model | 手机型号 | |
| pixelRatio | 设备像素比 | |
| screenWidth | 屏幕宽度 | 1.1.0 |
| screenHeight | 屏幕高度 | 1.1.0 |
| windowWidth | 可使用窗口宽度 | |
| windowHeight | 可使用窗口高度 | |
| language | 微信设置的语言 | |
| version | 微信版本号 | |
| system | 操作系统版本 | |
| platform | 客户端平台 | |
| SDKVersion | 客户端基础库版本 | 1.1.0 |
示例代码:
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 sometShopfang when catch error
}
wx.canIUse(String)
判断小程序的API,回调,参数,组件等是否在当前版本可用。
String参数说明:
使用${API}.${method}.${param}.${options}或者${component}.${attribute}.${option}方式来调用,例如:
-
${API}代表 API 名字 -
${method}代表调用方式,有效值为return,success,object,callback -
${param}代表参数或者返回值 -
${options}代表参数的可选值 -
${component}代表组件名字 -
${attribute}代表组件属性 -
${option}代表组件属性的可选值
例子:
wx.canIUse('openBluetoothAdapter')wx.canIUse('getSystemInfoSync.return.screenWidth')
wx.canIUse('getSystemInfo.success.screenWidth')
wx.canIUse('showToast.object.image')
wx.canIUse('onCompassChange.callback.direction')
wx.canIUse('request.object.method.GET')
wx.canIUse('contact-button')
wx.canIUse('text.selectable')
wx.canIUse('button.open-type.contact')
更多微信小程序开发教程,可以关注Shopfa小程序。
第二部分:如何开通一个小商店
相关文章
****更多行业产品开发方案,请关注 加速度JSUDO***
<以上资讯仅供参考,如果您需解决具体问题,建议您关注作者;如果有软件产品开发需求,可在线咨询加速度产品经理获取方案和报价>
加速度JSUDO是一家企业级数字化解决方案提供商,专注于软件开发、网络营销、数字化转型咨询及云计算服务。核心业务包括定制化ERP/CRM系统、快速应用开发、大数据分析及物联网(IoT)解决方案,助力企业提升效率与智能化水平。服务覆盖制造业、零售、物流等多行业,致力于通过技术创新推动客户数字化转型。
添加客服微信获取更多内容










