@capacitor/action-sheet
Action Sheet API 提供访问原生 Action Sheets(操作列表)的功能,这些列表从屏幕底部弹出并显示用户可执行的操作。
安装
npm install @capacitor/action-sheet
npx cap sync
变量
本插件将使用以下项目变量(在应用的 variables.gradle 文件中定义):
$androidxMaterialVersion:com.google.android.material:material的版本(默认值:1.3.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('Action Sheet 结果:', result);
};
API
showActions(...)
showActions(options: ShowActionsOptions) => Promise<ShowActionsResult>