页面中的非浮层元素,不会自动消失。

    Alert 组件提供四种主题,由属性指定,默认值为info

    主题

    Alert 组件提供了两个不同的主题:lightdark

    Alert 警告 - 图1

    1. <template>
    2. <el-alert
    3. title="成功提示的文案"
    4. type="success"
    5. effect="dark">
    6. </el-alert>
    7. <el-alert
    8. title="消息提示的文案"
    9. type="info"
    10. </el-alert>
    11. <el-alert
    12. title="警告提示的文案"
    13. type="warning"
    14. effect="dark">
    15. </el-alert>
    16. title="错误提示的文案"
    17. type="error"
    18. effect="dark">
    19. </el-alert>
    20. </template>

    自定义关闭按钮

    自定义关闭按钮为文字或其他符号。

    在 Alert 组件中,你可以设置是否可关闭,关闭按钮的文本以及关闭时的回调函数。closable属性决定是否可关闭,接受boolean,默认为true。你可以设置close-text属性来代替右侧的关闭图标,注意:close-text必须为文本。设置close事件来设置关闭时的回调。

    表示某种状态时提升可读性。

    Alert 警告 - 图2

    1. <template>
    2. <el-alert
    3. title="成功提示的文案"
    4. type="success"
    5. show-icon>
    6. </el-alert>
    7. <el-alert
    8. type="info"
    9. </el-alert>
    10. <el-alert
    11. title="警告提示的文案"
    12. type="warning"
    13. show-icon>
    14. </el-alert>
    15. <el-alert
    16. title="错误提示的文案"
    17. type="error"
    18. show-icon>
    19. </el-alert>
    20. </template>

    文字居中

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

    带有辅助性文字介绍

    包含标题和内容,解释更详细的警告。

    Alert 警告 - 图3

    除了必填的title属性外,你可以设置description属性来帮助你更好地介绍,我们称之为辅助性文字。辅助性文字只能存放单行文本,会自动换行显示。

    1. <template>
    2. <el-alert
    3. title="带辅助性文字介绍"
    4. type="success"
    5. description="这是一句绕口令:黑灰化肥会挥发发灰黑化肥挥发;灰黑化肥会挥发发黑灰化肥发挥。 黑灰化肥会挥发发灰黑化肥黑灰挥发化为灰……">

    最后,这是一个同时具有 icon 和辅助性文字的样例。

    Attributes

    Slot