@capacitor/action-sheet
Action Sheet API 提供对原生操作表的访问,操作表从屏幕底部弹出,显示用户可以执行的操作。
安装
npm install @capacitor/action-sheet
npx cap sync
变量
该插件将使用以下项目变量(定义在您应用的 variables.gradle 文件中):
androidxMaterialVersion:com.google.android.material:material的版本(默认值:1.8.0)
PWA 注意事项
Action Sheet 插件正常工作需要 PWA Elements。
示例
import { ActionSheet, ActionSheetButtonStyle } from '@capacitor/action-sheet';
const showActions = async () => {
const result = await ActionSheet.showActions({
title: '照片选项',
message: '选择一个操作',
options: [
{
title: '上传',
},
{
title: '分享',
},
{
title: '删除',
style: ActionSheetButtonStyle.Destructive,
},
],
});
console.log('操作表结果:', result);
};
API
showActions(...)
showActions(options: ShowActionsOptions) => Promise<ShowActionsResult>