Skip to content

轻提示

Toast Props ​

名称类型默认值说明
typeToastType'info'提示的类型,可选 info、success、warning、error;error 类型会自动应用 role="alert"。
bodystring-提示的正文文本,默认渲染在提示内容区。
autoClosebooleantrue是否在 duration 之后自动关闭。
durationnumber5000自动关闭前的停留时长,单位毫秒。

Toast 事件 ​

名称说明
close提示关闭时触发,无论是自动关闭还是手动关闭。

Toast Slots ​

名称说明
default自定义提示的内容区域,未提供时默认显示 body 文本。

ToastViewport Props ​

名称类型默认值说明
placementToastPlacement'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()