Skip to content

Message 消息提示

在页面顶部展示非阻塞反馈。支持成功、警告、信息、错误四种类型,也支持常驻、手动关闭和相同消息合并。

基础用法

消息类型与合并

连续发送相同消息可查看合并计数效果。

vue

调用方式

js
import { AuMessage } from 'aurora-plus';

const handler = AuMessage.success('保存成功');
handler.close();

AuMessage.warning({
  message: '请检查输入内容',
  duration: 3000,
  showClose: true,
});

Message API

方法

方法参数返回值说明
AuMessage(options)string / number / AuMessageOptionsAuMessageHandler打开消息;未指定类型时为 info
AuMessage.success(options)同上AuMessageHandler打开成功消息
AuMessage.warning(options)同上AuMessageHandler打开警告消息
AuMessage.info(options)同上AuMessageHandler打开信息消息
AuMessage.error(options)同上AuMessageHandler打开错误消息
AuMessage.closeAll()void关闭当前全部消息

AuMessageHandler 包含一个 close(): void 方法,可精确关闭本次调用创建或合并到的消息。

四种消息类型使用相同的默认关闭时长。AuMessage.error() 默认也会自动关闭;只有显式传入 duration: 0 时,消息才会常驻并等待手动关闭。

Options

配置说明类型默认值
message消息正文string / number必填
type消息类型success / warning / info / errorinfo
duration显示时长,单位 ms;0 表示常驻number2000
showClose是否显示关闭按钮booleanfalse
grouping是否合并相同类型与正文并累加次数booleanfalse
offset消息容器距视口顶部的距离,单位 pxnumber20
onClose消息关闭后的回调() => void

鼠标悬停在消息上会暂停自动关闭计时,移出后从剩余时间继续。

Aurora Plus · Vue 3 Component Library