tt.canIUse

2020-02-11 21:07 更新
基礎(chǔ)庫 1.35.0 開始支持本方法,這是一個同步方法。

判斷小程序的 API,回調(diào),參數(shù),組件等是否在當(dāng)前版本可用。


參數(shù)

string schema

使用 ${API}.${method}.${param}.${option} 或者 ${component}.${attribute}.${option} 方式來調(diào)用。

詳細(xì)說明

  • ${API} 代表 API 名字
  • ${method} 代表調(diào)用方式,有效值為 return, success, object, callback
  • ${param} 代表參數(shù)或者返回值
  • ${option} 代表參數(shù)的可選值或者返回值的屬性
  • ${component} 代表組件名字
  • ${attribute} 代表組件屬性
  • ${option} 代表組件屬性的可選值


返回值

boolean

當(dāng)前版本是否可用。


代碼示例

// 對象的屬性或方法
tt.canIUse("UpdateManager");
tt.canIUse("Stats.isDirectory");

// tt接口參數(shù)、回調(diào)或者返回值
tt.canIUse("exitMiniProgram");
tt.canIUse("getLaunchOptionsSync.return.path");
tt.canIUse("getSystemInfo.success.screenWidth");
tt.canIUse("showToast.object.title");
tt.canIUse("onCompassChange.callback.direction");
tt.canIUse("request.object.method.GET");

// 組件的屬性
tt.canIUse("swiper");
tt.canIUse("text.selectable");
tt.canIUse("button.open-type.contact");
以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號