@capacitor/toast
Toast API 提供了一个通知弹窗,用于向用户显示重要信息。
安装
npm install @capacitor/toast
npx cap sync
PWA 说明
Toast 插件需要 PWA Elements 才能工作。
示例
import { Toast } from '@capacitor/toast';
const showHelloToast = async () => {
await Toast.show({
text: 'Hello!',
});
};
API
show(...)
show(options: ShowOptions) => Promise<void>
在屏幕上显示 Toast
| 参数 | Type |
|---|---|
options | |
始于: 1.0.0
接口
ShowOptions
| 属性 | Type | 描述 | 默认 值 | 始于 |
|---|---|---|---|---|
text | string | Toast 上显示的文字 | 1.0.0 | |
duration | 'short' | 'long' | Toast 的持续时间,'short'(2000ms)或 'long'(3500ms) | 'short' | 1.0.0 |
position | 'top' | 'center' | 'bottom' | Toast 的位置 | 'bottom' | 1.0.0 |