跳过内容

开始使用

GitHub

您可以使用我们的AI辅助设置来安装插件。将Capgo技能添加到您的AI工具中,使用以下命令:

终端窗口
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

然后使用以下提示:

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-pretty-toast` plugin in my project.

如果您更喜欢手动设置,请按照以下命令安装插件,并遵循以下平台特定的说明:

终端窗口
npm install @capgo/capacitor-pretty-toast
npx cap sync
import { toast } from '@capgo/capacitor-pretty-toast';

显示一个 Toast

标题:显示一个 Toast
toast.success('Saved', {
message: 'Your changes are ready.',
});

更新一个加载中的 Toast

标题:更新一个加载中的 Toast
const id = toast.loading('Uploading', {
message: 'Waiting for the server response.',
});
setTimeout(() => {
toast.update(id, {
title: 'Upload complete',
message: 'The file was stored successfully.',
icon: 'checkmark.circle.fill',
autoDismiss: true,
});
}, 1500);

跟踪一个 Promise

标题:跟踪一个 Promise
await toast.promise(uploadFile(), {
loading: {
title: 'Uploading',
message: 'Keep the app open while the file is sent.',
},
success: 'Uploaded',
error: 'Upload failed',
});

使用 icon 为符号名称或原始 SVG 标记:

toast.info('New message', {
icon: 'message.fill',
message: 'Open the inbox to reply.',
});

使用 iconSource 为 URI 类型的图像。它支持 https://, http://, file://, data:, blob:, 绝对文件路径,或 { uri }.

toast.show({
title: 'Profile updated',
message: 'Your avatar changed.',
iconSource: 'https://example.com/avatar.png',
});

iconSource 优先于 icon.

如果您正在使用 开始使用 来规划原生插件工作,连接它与 Capgo 插件目录 为产品工作流程在 Capgo 插件目录 Capacitor 由 Capgo 插件 为实现细节在 Capacitor 由 Capgo 插件 添加或更新插件 为实现细节在添加或更新插件 Ionic 企业插件替代品 为产品工作流程在 Ionic 企业插件替代品, 和 Capgo 原生构建 为产品工作流程在 Capgo 原生构建。