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

参数类型默认值说明
titlestring通知标题
contentstring通知内容(必填)
durationnumber4500自动关闭时间(ms),0 为不关闭