新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
創(chuàng)新互聯(lián)小程序教程:微信小程序API-設(shè)備-系統(tǒng)信息
wx.getSystemInfo(OBJECT)
獲取系統(tǒng)信息。
OBJECT參數(shù)說明:
| 參數(shù) | 類型 | 必填 | 說明 |
|---|---|---|---|
| success | Function | 是 | 接口調(diào)用成功的回調(diào) |
| fail | Function | 否 | 接口調(diào)用失敗的回調(diào)函數(shù) |
| complete | Function | 否 | 接口調(diào)用結(jié)束的回調(diào)函數(shù)(調(diào)用成功、失敗都會(huì)執(zhí)行) |
success回調(diào)參數(shù)說明:
| 參數(shù) | 說明 | 最低版本 |
|---|---|---|
| model | 手機(jī)型號(hào) | |
| pixelRatio | 設(shè)備像素比 | |
| screenWidth | 屏幕寬度 | 1.1.0 |
| screenHeight | 屏幕高度 | 1.1.0 |
| windowWidth | 可使用窗口寬度 | |
| windowHeight | 可使用窗口高度 | |
| language | 微信設(shè)置的語言 | |
| version | 微信版本號(hào) | |
| system | 操作系統(tǒng)版本 | |
| platform | 客戶端平臺(tái) | |
| fontSizeSetting | 用戶字體大小設(shè)置。以“我-設(shè)置-通用-字體大小”中的設(shè)置為準(zhǔn),單位:px | 1.5.0 |
| SDKVersion | 客戶端基礎(chǔ)庫(kù)版本 | 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()
獲取系統(tǒng)信息同步接口
同步返回參數(shù)說明:
| 參數(shù) | 說明 | 最低版本 |
|---|---|---|
| model | 手機(jī)型號(hào) | |
| pixelRatio | 設(shè)備像素比 | |
| screenWidth | 屏幕寬度 | 1.1.0 |
| screenHeight | 屏幕高度 | 1.1.0 |
| windowWidth | 可使用窗口寬度 | |
| windowHeight | 可使用窗口高度 | |
| language | 微信設(shè)置的語言 | |
| version | 微信版本號(hào) | |
| system | 操作系統(tǒng)版本 | |
| platform | 客戶端平臺(tái) | |
| SDKVersion | 客戶端基礎(chǔ)庫(kù)版本 | 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,回調(diào),參數(shù),組件等是否在當(dāng)前版本可用。
String參數(shù)說明: 使用${API}.${method}.${param}.${options}或者${component}.${attribute}.${option}方式來調(diào)用,例如:
${API}代表 API 名字${method}代表調(diào)用方式,有效值為return,success,object,callback${param}代表參數(shù)或者返回值${options}代表參數(shù)的可選值${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')
當(dāng)前文章:創(chuàng)新互聯(lián)小程序教程:微信小程序API-設(shè)備-系統(tǒng)信息
轉(zhuǎn)載來源:http://m.fisionsoft.com.cn/article/djgehcj.html


咨詢
建站咨詢
