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/ui/interaction/showActionSheet.md.

showActionSheet

显示操作菜单。

扫码预览

扫码预览 showActionSheet

支持版本

前端库版本不低于 0.0.26。

支持平台

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

支持场景

场景支持情况
页面支持
卡片支持

使用说明

  • itemList 必填;用户点击菜单外区域取消时 Promise reject,请在 catch 中处理取消场景。

调用方式

异步 API

showActionSheet(params: ShowActionSheetParams): Promise<ShowActionSheetResult>

入参

名称类型必填默认值约束说明
itemColorstring否-十六进制颜色字符串,例如 #000000。按钮文字颜色。
itemListstring[]是--按钮文字数组。
titlestring否--标题。

调用示例

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

const result = await showActionSheet({
  itemList: ['编辑', '删除']
});

console.log(result.tapIndex);

成功返回

名称类型必返说明
tapIndexnumber是用户点击的按钮序号,从 0 开始。

返回示例

{
  "tapIndex": 0
}

错误处理

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

失败示例

{
  "errNo": 114,
  "errMsg": "operation cancelled"
}

错误码

errNoerrMsg平台触发条件处理建议
104invalid parameterAndroid、iOSitemList 为空数组传入至少一个菜单项后重试。
114operation cancelledAndroid、iOS用户点击 Cancel 按钮或点击蒙层关闭操作菜单用户主动取消,按需静默处理。

通用错误码

errNoerrMsg说明平台
102internal error内部错误Android、iOS