# Message 消息提示
常用于主动操作后的反馈提示。与 Notification 的区别是后者更多用于系统级通知的被动提醒。
# 基础用法
从顶部出现,3 秒后自动消失。
# 其他用法
# 文字居中和 html 片段
使用 center
属性让文字水平居中。
# Options
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|---|---|---|---|
message | 消息文字 | string / VNode | — | — |
type | 主题 | string | success/warning/info/error | info |
iconClass | 自定义图标的类名,会覆盖 type | string | — | — |
dangerouslyUseHTMLString | 是否将 message 属性作为 HTML 片段处理 | boolean | — | false |
customClass | 自定义类名 | string | — | — |
duration | 显示时间, 毫秒。设为 0 则不会自动关闭 | number | — | 3000 |
showClose | 是否显示关闭按钮 | boolean | — | false |
center | 文字是否居中 | boolean | — | false |
onClose | 关闭时的回调函数, 参数为被关闭的 message 实例 | function | — | — |
offset | Message 距离窗口顶部的偏移量 | number | — | 20 |
# 方法
调用 Message
或 this.$message
会返回当前 Message 的实例。如果需要手动关闭实例,可以调用它的 close
方法。
方法名 | 说明 |
---|---|
close | 关闭当前的 Message |