Toast 轻提示
轻量的全局反馈提示,支持 success、error、info 三种类型,自动消失。
基础用法
调用 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) | number | 2000 |
CSS 变量
| 变量 | 说明 | 默认值 |
|---|---|---|
--toast-text-color | 文字颜色 | #f5f7f9 |