my.canIUse(String)
Esta API es compatible con mPaaS 10.1.32 y versiones posteriores.
Esta interfaz determina si la versión actual admite la API, los parámetros de entrada, los valores de retorno, los componentes y los atributos del mini programa actual.
Parámetro de entrada
Los parámetros se especifican mediante el método ${API}.${type}.${param}.${option} o ${component}.${attribute}.${option}.
API: indica el nombre de la API; excluya el prefijo my.. Por ejemplo, para verificar my.getFileInfo, pase solo getFileInfo.
type: los valores posibles son object/return/callback, que indican el tipo de verificación de la API.
param: indica un nombre de atributo del parámetro.
option: indica el valor específico del atributo del parámetro.
component: indica el nombre del componente.
attribute: indica el nombre del atributo del componente.
option: indica el valor del atributo del componente.
Ejemplo de código
// Whether the new API is available
my.canIUse('getFileInfo')
// Whether the new API attribute is available
my.canIUse('closeSocket.object.code')
// Whether the new API attribute is available
my.canIUse('getLocation.object.type')
// Whether the new attribute of the API return value is available
my.canIUse('getSystemInfo.return.brand')
// Whether the new component "Follow lifestyle account" is available
my.canIUse('lifestyle')
// Whether the new attribute value of the component is available
my.canIUse('button.open-type.share')
Valor de retorno
Tipo booleano que indica si es compatible.