For AI agents: the complete documentation index is available at /apps-plugin/docs/llms.txt, the full documentation bundle is available at /apps-plugin/docs/llms-full.txt, and this page is available as Markdown at /apps-plugin/docs/js-api/basic/canIUse.md.

canIUse

检测当前环境是否支持指定 API 或能力。

支持版本

前端库版本不低于 0.0.14。

支持平台

平台支持情况
Android支持
iOS支持
PC不支持
HarmonyOS不支持

调用方式

异步 API

canIUse(params: CanIUseParams): Promise<CanIUseResult>

入参

名称类型必填默认值约束说明
schemastring是--需要检测的能力标识,例如 API 名称

调用示例

import { canIUse } from '@doubao-dev/framework/api';

const { result } = await canIUse({ schema: 'doubao.getLocation' });
console.log('是否支持 getLocation:', result);

成功返回

名称类型必返说明
resultboolean是是否支持所检测的能力

返回示例

{
  "result": true
}

错误处理

错误对象和通用错误码见 通用错误处理。

失败示例

{
  "errNo": 600001,
  "errMsg": "invalid parameter"
}

错误码

errNoerrMsg平台触发条件处理建议
600001invalid parameterAndroid、iOSschema 为空或格式不合法传入有效的 schema 字符串,格式为"命名空间.方法名"