Skip to content

Alert 提示 ​

用于页面中展示重要的提示信息。

ts
import { createApp } from 'vue'
import { ElAlert } from '@szhn/dh-design-pc'

const app = createApp()
app.use(ElAlert)

基础用法 ​

Alert 组件不属于浮层元素,不会自动消失或关闭。提供 5 种类型,由 type 属性指定,默认值为 info。

主题 ​

Alert 提供了 light 和 dark 两种主题,通过 effect 属性切换。

自定义关闭按钮 ​

可以通过 closable 控制 Alert 是否可关闭,close-text 用来自定义关闭按钮文本,关闭时触发 close 事件。

使用图标 ​

通过 show-icon 属性展示类型对应的图标,使提示信息更易识别。

文字居中 ​

使用 center 属性使文字水平居中。

文字描述 ​

通过 description 属性添加辅助性描述,可以让用户了解更多信息。

带图标和描述 ​

同时配合 show-icon 和 description,可以获得信息量更完整的提示。

API ​

属性 ​

名称说明类型默认值
title标题string—
type类型success / warning / info / error / primaryinfo
description描述性文本string—
closable是否可以关闭booleantrue
center文字是否居中booleanfalse
close-text自定义关闭按钮文本string—
show-icon是否显示类型图标booleanfalse
effect主题样式light / darklight

事件 ​

名称说明
close关闭 Alert 时触发

插槽 ​

名称说明
defaultAlert 内容描述
title标题的内容
icon图标的内容

更多配置参见 Element Plus Alert。