Alert 提示
用于展示重要的提示信息。
基础用法
提示组件是页面中的非浮层元素,不会自动消失。
通过 type 定义 5 种主题,默认值为 info。
Primary alert
Success alert
Info alert
Warning alert
Error alert
主题
提供 light 与 dark 两种主题。
使用 effect 切换主题,默认为 light。
Primary alert
Success alert
Info alert
Warning alert
Error alert
自定义关闭按钮
可将关闭按钮自定义为文字或其他符号。
可配置是否可关闭;关闭按钮文案与关闭回调均可自定义。closable 决定组件是否可关闭,类型为 boolean,默认 true。close-text 用于替换默认的叉号,必须为字符串。组件关闭时触发 close 事件。
Unclosable alert
Customized close text
Gotcha
Alert with callback
带图标
展示图标有助于提升可读性。
设置 show-icon 可显示与当前类型对应的图标,或使用 icon 插槽自定义图标。
Primary alert
Success alert
Info alert
Warning alert
Error alert
Error alert with custom icon
文字居中
使用 center 属性让内容居中。
Primary alert
Success alert
Info alert
Warning alert
Error alert
带辅助性文字
辅助性文字可展示更详细的信息。
除必填的 title 外,可设置 description 展示更详细的说明。description 仅支持字符串,会自动换行。
With description
This is a description.
同时带图标与辅助性文字
以下为同时包含图标与辅助性文字的示例。
Primary alert
More text description
Success alert
More text description
Info alert
More text description
Warning alert
More text description
Error alert
More text description
提示 API
提示 属性
| 名称 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| title | 标题 | string | — |
| type | 类型 | enum | info |
| description | 辅助性文字 | string | — |
| closable | 是否可关闭 | boolean | true |
| center | 内容是否居中 | boolean | false |
| close-text | 关闭按钮自定义文字 | string | — |
| show-icon | 是否显示类型图标 | boolean | false |
| effect | 主题样式 | enum | light |
提示 事件
| 事件名 | 说明 | 类型 |
|---|---|---|
| close | 关闭时触发 | Function |
提示 插槽
| 名称 | 说明 |
|---|---|
| default | 辅助性文字内容 |
| title | 标题内容 |
| icon | 图标内容 |