Notification 通知提醒框
全局通知组件,通过 useNotification 组合式函数调用。支持 4 种语义类型、自定义时长和仅内容模式。
不同类型
通知有 4 种语义类型:info、success、warning、error。
仅内容
省略 title 只显示内容文本,通知框更简洁紧凑。
自定义时长
通过 duration 设置自动关闭时间(毫秒),设为 0 则不自动关闭。
字符串简写
传入字符串可直接作为 content,无需对象形式。
useNotification() 返回值
| 方法 | 类型 | 说明 |
|---|---|---|
notify | (opts: NotificationOption | string) => void | 通用通知(默认 info) |
notify.info | (opts: NotificationOption | string) => void | 信息通知 |
notify.success | (opts: NotificationOption | string) => void | 成功通知 |
notify.warning | (opts: NotificationOption | string) => void | 警告通知 |
notify.error | (opts: NotificationOption | string) => void | 错误通知 |
NotificationOption
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
title | string | — | 通知标题 |
content | string | — | 通知内容(必填) |
duration | number | 4500 | 自动关闭时间(ms),0 为不关闭 |