微信小程序开发 专题
专题目录
您的位置:微信小程序开发 > 微信小程序开发专题 > 微信小程序API-设备-系统信息
微信小程序API-设备-系统信息
作者:--    发布时间:2019-11-20

获取系统信息。

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 something when catch error
}

wx.caniuse(string)

判断小程序的api,回调,参数,组件等是否在当前版本可用。

string参数说明: 使用${api}.${method}.${param}.${options}或者${component}.${attribute}.${option}方式来调用,例如:

  • ${api}代表 api 名字
  • ${method}代表调用方式,有效值为returnsuccessobjectcallback
  • ${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')


网站声明:
本站部分内容来自网络,如您发现本站内容
侵害到您的利益,请联系本站管理员处理。
联系站长
373515719@qq.com
关于本站:
编程参考手册