轻提示
Toast Props
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
type | ToastType | 'info' | 提示的类型,可选 info、success、warning、error;error 类型会自动应用 role="alert"。 |
body | string | - | 提示的正文文本,默认渲染在提示内容区。 |
autoClose | boolean | true | 是否在 duration 之后自动关闭。 |
duration | number | 5000 | 自动关闭前的停留时长,单位毫秒。 |
Toast 事件
| 名称 | 说明 |
|---|---|
close | 提示关闭时触发,无论是自动关闭还是手动关闭。 |
Toast Slots
| 名称 | 说明 |
|---|---|
default | 自定义提示的内容区域,未提供时默认显示 body 文本。 |
ToastViewport Props
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
placement | ToastPlacement | 'bottom-center' | 提示在屏幕上的弹出位置,可选 top-start、top-center、top-end、bottom-start、bottom-center、bottom-end。 |
useToast
ts
const toast = useToast()
const dismiss = toast({ body: 'Hello', type: 'info', duration: 3000 })
// 手动关闭
dismiss()
// 关闭全部
toast.clear()