跳到主要内容
版本:v8

@capacitor/toast

提示 API 提供了一个通知弹出窗口,用于向用户显示重要信息。就像真正的吐司一样!

安装

npm install @capacitor/toast
npx cap sync

PWA 注意事项

提示插件需要 PWA Elements 才能工作。

示例

import { Toast } from '@capacitor/toast';

const showHelloToast = async () => {
await Toast.show({
text: '你好!',
});
};

API

show(...)

show(options: ShowOptions) => Promise<void>

在屏幕上显示提示

ParamType
options
ShowOptions

Since: 1.0.0


Interfaces

ShowOptions

PropTypeDescriptionDefaultSince
textstring在提示上显示的文本1.0.0
duration'short' | 'long'提示的持续时间,可以是 'short'(2000ms) 或 'long'(3500ms)'short'1.0.0
position'top' | 'center' | 'bottom'提示的位置。在 Android 12 及更高版本上,所有提示都在底部显示。'bottom'1.0.0