微信小程序API-设备-系统信息


当前第2页 返回上一页

同步返回参数说明:

参数 说明 最低版本
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')



标签:微信小程序

返回前面的内容

相关阅读 >>

微信小程序 扩展组件粘性布局组件

微信小程序 wxs模块

微信小程序api中,使用drawimage完成绘制图像,图像保持原始尺寸

微信小程序api 电量

微信小程序api 图片-压缩图片接口

微信小程序api 绘图fill(对当前路径进行填充)

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

微信小程序 广告-插屏广告

微信小程序云开发 兼容性问题

微信小程序云开发api update

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




打赏

取消

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

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

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

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

评论

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

    正在狠努力加载,请稍候...