Skip to content

Message 消息提示

全局轻量提示信息。支持四种类型、六种位置、可选图标、自动关闭与手动关闭。

基础用法

提供 infosuccesswarningerror 四种类型的消息提示。

自定义关闭时间

通过 duration 控制自动关闭时间,设为 0 表示不自动关闭。

不同位置

通过 position 设置消息显示位置,支持六种位置。

自定义内容

通过 render 传入自定义 VNode 内容。

API

Options

CMessage(options) 支持以下选项:

参数说明类型默认值
type消息类型'info' | 'success' | 'warning' | 'error''info'
message文本消息内容(与 render 二选一)string
duration自动关闭时间(毫秒),设为 0 表示不自动关闭number3000
showIcon是否显示类型图标booleantrue
closable是否显示关闭按钮booleanfalse
position展示位置'top' | 'bottom' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right''top'
render自定义渲染函数(Vue VNode)() => VNode
onClose关闭时回调() => void