跳转到正文

@capgo/capacitor-pretty-toast

原生风格 Toast,支持 loading 和 promise 辅助函数。

使用 toast.success() 以及 toast.loading() 而不是用阻塞式弹窗来提供轻量反馈。

平台支持备注
iOS是原生界面
Android是Material 风格
Web 端是DOM 回退方案
在外部设备上运行的 Animated Pretty Toast 演示
Toast 通知流程
  • toast.show - 通过完整的配置对象显示自定义 toast。
  • toast.success, toast.error, toast.info, toast.warning - 通过标题和可选配置显示常见的语义化 toast。
  • toast.loading - 显示一个常驻的加载中 toast。
  • toast.update - 原地更新现有的 toast。
  • toast.promise - 跟踪 Promise 的 loading、success 和 error 状态。
  • toast.dismiss 以及 toast.dismissAll - 移除单个 toast 或清空队列。
方法描述
toast.show(config, options?)使用完整配置显示 toast ToastConfig.
toast.success(title, config?, options?)显示成功 toast。
toast.error(title, config?, options?)显示错误 toast。
toast.info(title, config?, options?)显示一条信息 Toast。
toast.warning(title, config?, options?)显示一条警告 Toast。
toast.loading(title, config?, options?)显示一条加载中 Toast,默认不会自动消失。
toast.update(id, partial)更新现有的 Toast。
toast.promise(promise, messages)显示加载状态,然后更新为成功或错误状态。
toast.dismiss(id?)关闭单个 Toast 或当前活跃的 Toast。
toast.dismissAll()关闭所有可见和排队中的 Toast。

此参考文档同步自 src/definitions.ts 中的 capacitor-pretty-toast.

如果你正在使用 @capgo/capacitor-pretty-toast 要规划原生插件工作,请将其与 Capgo 插件目录 查看 Capgo 插件目录中的产品工作流, Capgo 提供的 Capacitor 插件 查看由 Capgo 提供的 Capacitor 插件中的实现细节, 添加或更新插件 查看添加或更新插件中的实现细节, Ionic Enterprise 插件替代方案 查看 Ionic Enterprise 插件替代方案中的产品工作流,以及 Capgo Native Build 查看 Capgo Native Builds 中的产品工作流。