Appearance
Message 消息提示
全局轻量提示信息。支持四种类型、六种位置、可选图标、自动关闭与手动关闭。
基础用法
提供 info、success、warning、error 四种类型的消息提示。
自定义关闭时间
通过 duration 控制自动关闭时间,设为 0 表示不自动关闭。
不同位置
通过 position 设置消息显示位置,支持六种位置。
自定义内容
通过 render 传入自定义 VNode 内容。
API
Options
CMessage(options) 支持以下选项:
| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| type | 消息类型 | 'info' | 'success' | 'warning' | 'error' | 'info' |
| message | 文本消息内容(与 render 二选一) | string | — |
| duration | 自动关闭时间(毫秒),设为 0 表示不自动关闭 | number | 3000 |
| showIcon | 是否显示类型图标 | boolean | true |
| closable | 是否显示关闭按钮 | boolean | false |
| position | 展示位置 | 'top' | 'bottom' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'top' |
| render | 自定义渲染函数(Vue VNode) | () => VNode | — |
| onClose | 关闭时回调 | () => void | — |