@capacitor/dialog
Dialog API 提供触发原生对话框窗口的方法,用于警告、确认和输入提示
安装
npm install @capacitor/dialog@latest-5
npx cap sync
示例
import { Dialog } from '@capacitor/dialog';
const showAlert = async () => {
await Dialog.alert({
title: 'Stop',
message: 'this is an error',
});
};
const showConfirm = async () => {
const { value } = await Dialog.confirm({
title: 'Confirm',
message: `Are you sure you'd like to press the red button?`,
});
console.log('Confirmed:', value);
};
const showPrompt = async () => {
const { value, cancelled } = await Dialog.prompt({
title: 'Hello',
message: `What's your name?`,
});
console.log('Name:', value);
console.log('Cancelled:', cancelled);
};
API
alert(...)
alert(options: AlertOptions) => Promise<void>