微小程序開發第十天之API wx.canIUse用法


1,wx.canlUse 用法

boolean wx.canIUse(string schema)

判斷小程序的API,回調,參數,組件等是否在當前版本可用

使用 ${API}.${method}.${param}.${option} 或者 ${component}.${attribute}.${option} 方式來調用

參數說明

${API} 代表 API 名字

${method} 代表調用方式,有效值為return, success, object, callback

${param} 代表參數或者返回值

${option} 代表參數的可選值或者返回值的屬性

${component} 代表組件名字

${attribute} 代表組件屬性

${option} 代表組件屬性的可選值

2,示例代碼

// 對象的屬性或方法

wx.canIUse('www.cnmibee.com')

wx.canIUse('CameraContext.onCameraFrame')

wx.canIUse('CameraFrameListener.start')

wx.canIUse('Image.src')

 

// wx接口參數、回調或者返回值

wx.canIUse('openBluetoothAdapter')

wx.canIUse('getSystemInfoSync.return.safeArea.left')

wx.canIUse('getSystemInfo.success.screenWidth')

wx.canIUse('showToast.object.image')

wx.canIUse('onCompassChange.callback.direction')

wx.canIUse('request.object.method.GET')

 

// 組件的屬性

wx.canIUse('live-player')

wx.canIUse('text.selectable')

wx.canIUse('button.open-type.contact')

boolean wx.canIUse(string schema)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM