Skip to content
Power

Notification 通知

通知组件,用于显示系统通知消息。

基础用法

显示代码

快捷方法

ts
import { M_Notification } from "@/package/components/feedback";

// 成功通知
M_Notification.success({
  title: "成功",
  message: "操作已完成"
});

// 警告通知
M_Notification.warning({
  title: "警告",
  message: "请注意"
});

// 错误通知(使用 danger)
M_Notification.danger({
  title: "错误",
  message: "操作失败"
});

// 信息通知
M_Notification.info({
  title: "提示",
  message: "新消息"
});

// 关闭所有通知
M_Notification.closeAll();

NotificationOptions

属性名描述类型默认值
title通知标题,支持多语言Record<"en-US" | "zh-CN", string>
message通知消息,支持多语言Record<"en-US" | "zh-CN", string>
type通知类型,影响通知样式"primary" | "success" | "warning" | "danger" | "info"primary
duration通知显示时间,单位毫秒number4500
position通知位置"top-right" | "top-left" | "bottom-right" | "bottom-left"top-right
offset通知偏移量,单位像素number
customClass自定义通知类名string
dangerouslyUseHTMLString是否使用 HTML 字符串渲染消息booleanfalse
zIndex通知的 z-index 值number
onClick点击通知回调() => void
onClose关闭通知回调() => void

注意

类型使用 danger 而非 error,与其他组件保持一致。