Skip to content

Toast 轻提示

轻量的全局反馈提示,支持 successerrorinfo 三种类型,自动消失。

基础用法

调用 showToast 函数触发提示。

ts
import { showToast } from "@/components/toast/toast";

showToast("操作成功", "success");
showToast("请求失败", "error");
showToast("提示信息", "info");

自定义时长

第三个参数传入毫秒数,默认 2000ms

ts
showToast("短暂提示", "info", 1000);
showToast("持久提示", "info", 5000);

API

showToast 方法

参数说明类型默认值
message提示内容string
type提示类型'success' | 'error' | 'info''info'
duration显示时长(ms)number2000

CSS 变量

变量说明默认值
--toast-text-color文字颜色#f5f7f9