Notification 通知提醒框

大约 2 分钟

Notification 通知提醒框

全局展示通知提醒信息。

何时使用

在系统四个角显示通知提醒信息。经常用于以下情况:

  • 较为复杂的通知内容。
  • 带有交互的通知,给出用户下一步的行动点。
  • 系统主动推送。

示例

基本用法

GlobalAPI用法

API

  • notification.success(config)
  • notification.error(config)
  • notification.info(config)
  • notification.warning(config)
  • notification.warn(config)
  • notification.open(config)
  • notification.close(key: String)
  • notification.destroy()

config 参数如下:

参数说明类型默认值版本
bottom消息从底部弹出时,距离底部的位置,单位像素。string24px
btn自定义关闭按钮VNode | () => VNode-
class自定义 CSS classstring-
closeIcon自定义关闭图标VNode | () => VNode-
description通知提醒内容,必选string | VNode | () => VNode-
duration默认 4.5 秒后自动关闭,配置为 null 则不自动关闭number4.5
getContainer配置渲染节点的输出位置() => HTMLNode() => document.body
icon自定义图标VNode | () => VNode-
key当前通知唯一标志string-
message通知提醒标题,必选string | VNode | () => VNode-
placement弹出位置,可选 topLeft topRight bottomLeft bottomRightstringtopRight
style自定义内联样式Object | string-
top消息从顶部弹出时,距离顶部的位置,单位像素。string24px
onClick点击通知时触发的回调函数Function-
onClose点击默认关闭按钮时触发的回调函数Function-

还提供了一个全局配置方法,在调用前提前配置,全局一次生效。

  • notification.config(options)

    当你使用 ConfigProvider 进行全局化配置时,系统会默认自动开启 RTL 模式。(3.0+)

    当你想单独使用,可通过如下设置开启 RTL 模式。

notification.config({
  placement: 'bottomRight',
  bottom: '50px',
  duration: 3,
  rtl: true,
});
参数说明类型默认值版本
bottom消息从底部弹出时,距离底部的位置,单位像素。string24px
closeIcon自定义关闭图标VNode | () => VNode-
duration默认自动关闭延时,单位秒number4.5
getContainer配置渲染节点的输出位置() => HTMLNode() => document.body
maxCount最大显示数, 超过限制时,最早的消息会被自动关闭number-3.0
placement弹出位置,可选 topLeft topRight bottomLeft bottomRightstringtopRight
rtl是否开启 RTL 模式booleanfalse3.0
top消息从顶部弹出时,距离顶部的位置,单位像素。string24px
上次编辑于:
贡献者: Noah.Su,jiapeng.duan