W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
獲取系統(tǒng)信息。
OBJECT參數(shù)說(shuō)明:
參數(shù) | 類型 | 必填 | 說(shuō)明 |
---|---|---|---|
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ù)說(shuō)明:
參數(shù) | 說(shuō)明 | 最低版本 |
---|---|---|
model | 手機(jī)型號(hào) | |
pixelRatio | 設(shè)備像素比 | |
screenWidth | 屏幕寬度 | 1.1.0 |
screenHeight | 屏幕高度 | 1.1.0 |
windowWidth | 可使用窗口寬度 | |
windowHeight | 可使用窗口高度 | |
language | 微信設(shè)置的語(yǔ)言 | |
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)
}
})
獲取系統(tǒng)信息同步接口
同步返回參數(shù)說(shuō)明:
參數(shù) | 說(shuō)明 | 最低版本 |
---|---|---|
model | 手機(jī)型號(hào) | |
pixelRatio | 設(shè)備像素比 | |
screenWidth | 屏幕寬度 | 1.1.0 |
screenHeight | 屏幕高度 | 1.1.0 |
windowWidth | 可使用窗口寬度 | |
windowHeight | 可使用窗口高度 | |
language | 微信設(shè)置的語(yǔ)言 | |
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
}
判斷小程序的API,回調(diào),參數(shù),組件等是否在當(dāng)前版本可用。
String參數(shù)說(shuō)明: 使用${API}.${method}.${param}.${options}
或者${component}.${attribute}.${option}
方式來(lái)調(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')
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: