跳过内容

Getting Started

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.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);
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.

如果您正在使用 Getting Started 为native插件工作做好规划,连接它 Capgo 插件目录 Capgo 插件目录中的产品工作流程 Capacitor 插件,Capgo Capacitor 插件,Capgo 的实现细节 添加或更新插件 添加或更新插件的实现细节 Ionic企业插件替代品 Ionic企业插件替代品中的产品工作流程 Capgo 原生构建 Capgo 原生构建中的产品工作流程