基本用法

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

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

 <template>
<el-alert
title="成功提示的文案"
type="success">
</el-alert>
<el-alert
title="消息提示的文案"
type="info">
</el-alert>
<el-alert
title="警告提示的文案"
type="warning">
</el-alert>
<el-alert
title="错误提示的文案"
type="error">
</el-alert>
</template>

自定义关闭按钮

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

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

 <template>
<el-alert
title="不可关闭的 alert"
type="success"
:closable="false">
</el-alert>
<el-alert
title="自定义 close-text"
type="info"
close-text="知道了">
</el-alert>
<el-alert
title="设置了回调的 alert"
type="warning"
@close="hello">
</el-alert>
</template> <script>
export default {
methods: {
hello() {
alert('Hello World!');
}
}
}
</script>

带有 icon

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

通过设置show-icon属性来显示 Alert 的 icon,这能更有效地向用户展示你的显示意图。

 <template>
<el-alert
title="成功提示的文案"
type="success"
show-icon>
</el-alert>
<el-alert
title="消息提示的文案"
type="info"
show-icon>
</el-alert>
<el-alert
title="警告提示的文案"
type="warning"
show-icon>
</el-alert>
<el-alert
title="错误提示的文案"
type="error"
show-icon>
</el-alert>
</template>

文字居中

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

 <template>
<el-alert
title="成功提示的文案"
type="success"
center
show-icon>
</el-alert>
<el-alert
title="消息提示的文案"
type="info"
center
show-icon>
</el-alert>
<el-alert
title="警告提示的文案"
type="warning"
center
show-icon>
</el-alert>
<el-alert
title="错误提示的文案"
type="error"
center
show-icon>
</el-alert>
</template>

带有辅助性文字介绍

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

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

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

带有 icon 和辅助性文字介绍

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

 <template>
<el-alert
title="成功提示的文案"
type="success"
description="文字说明文字说明文字说明文字说明文字说明文字说明"
show-icon>
</el-alert>
<el-alert
title="消息提示的文案"
type="info"
description="文字说明文字说明文字说明文字说明文字说明文字说明"
show-icon>
</el-alert>
<el-alert
title="警告提示的文案"
type="warning"
description="文字说明文字说明文字说明文字说明文字说明文字说明"
show-icon>
</el-alert>
<el-alert
title="错误提示的文案"
type="error"
description="文字说明文字说明文字说明文字说明文字说明文字说明"
show-icon>
</el-alert>
</template>

Attributes

参数 说明 类型 可选值 默认值
title 标题,必选参数 string
type 主题 string success/warning/info/error info
description 辅助性文字。也可通过默认 slot 传入 string
closable 是否可关闭 boolean true
center 文字是否居中 boolean true
close-text 关闭按钮自定义文本 string
show-icon 是否显示图标 boolean false

Events

事件名称 说明 回调参数
close 关闭alert时触发的事件

Alert 警告的更多相关文章

  1. [Swift通天遁地]一、超级工具-(15)使用SCLAlertView制作强大的Alert警告窗口和Input编辑窗口

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...

  2. alert警告框

    标签中写: <div class="alert alert-warning fade in"> <button class="close" d ...

  3. alert警告框点击确定后自动提交表单

    转载于  :https://zhidao.baidu.com/question/619375120140398412.html 在页面中有多个input type="text"的文 ...

  4. Bootstrap-Plugin:警告框(Alert)插件

    ylbtech-Bootstrap-Plugin:警告框(Alert)插件 1.返回顶部 1. Bootstrap 警告框(Alert)插件 警告框(Alert)消息大多是用来向终端用户显示诸如警告或 ...

  5. Bootstrap历练实例:警告框(Alert)插件事件

    事件 下表列出了警告框(Alert)插件中要用到的事件.这些事件可在函数中当钩子使用. 事件 描述 实例 close.bs.alert 当调用 close 实例方法时立即触发该事件. $('#myal ...

  6. amazeui学习笔记--js插件(UI增强)--警告框Alert

    amazeui学习笔记--js插件(UI增强)--警告框Alert 一.总结 1.警告框基本样式:用am-alert声明div容器, <div class="am-alert" ...

  7. iOS Webview 实现修改javascript confirm 和 alert

    贴代码: @interface UIWebView (JavaScriptAlert) -(void) webView:(UIWebView *)sender runJavaScriptAlertPa ...

  8. 三种对话框的示例(alert,confirm,prompt)

    示例代码 <h2>JavaScriptDialog</h2> <hr/> <buttononclick="btn_alert()"> ...

  9. prmopt 提示框接收字符串,输入后按确定弹出警告框,警告内容为逆序的字符串

    虽然已经找到offer,但因为公司还没安排实习,所以在学校的时间多了很多.好吧,这段时间我用来备考四级啦(好悲催,还没过),然后这一天,闲着无聊,就帮妹妹看了这样子一道题目啦. 题目内容: 编制一个从 ...

随机推荐

  1. js动态的往表格中加入表单元素

    效果如图: 这里我用的是layui的静态表格,其他框架也是一样的(只要你都表单元素要通过js进行渲染),我的需求是在表单中放了表格的元素,表格中还有表单的元素.表格中的行数据是js动态添加的,正常的添 ...

  2. PAT乙级1018

    题目链接 https://pintia.cn/problem-sets/994805260223102976/problems/994805304020025344 题解 刚开始做很懵逼,可能并不难吧 ...

  3. git生成公钥public key并添加SSH key。git乌龟gerrit下推送git【server sent :publickey】

    一.key 码云链接:http://git.mydoc.io/?t=180845#text_180845 博客链接: 方式一:https://blog.csdn.net/xb12369/article ...

  4. Autoprefixer:一个以最好的方式处理浏览器前缀的后处理程序

    Autoprefixer解析CSS文件并且添加浏览器前缀到CSS规则里,使用Can I Use的数据来决定哪些前缀是需要的.   所有你需要做的就是把它添加到你的资源构建工具(例如 Grunt)并且可 ...

  5. jenkins 批量修改svn 地址

    svn服务器的ip变了,jenkins里那么多任务一个个修改要疯了, 每个已经创建后的任务的svn 地址都配置在 jenkins 主目录下的jobs 里对应的任务下的config.xml 里 在job ...

  6. TXNLP 01-09

    一般涉及生成文本都是比较难的.

  7. webpack编译sass报错找不到module /css-loader/index.js... || 安装node-sass报错

    今天无论在家还是在公司,安装node-sass总是失败,或安装成功了,使用webpack编译sass报错,说找不到module,按照提示的错误我找了node_modules下的css-loader,发 ...

  8. Visual Studio 编译Winform程序不生成.vshost.exe和.pdb文件的方法

    问题:使用Visual Studio编译工程时,默认设置下,即使选择了「Release」时也会生成扩展名为「.vshost.exe」和「.pdb」的文件. 先解释一下各个文件的作用: .pdb文件: ...

  9. App 仿淘宝:控制详情和购买须知样式切换,控制商品详情和购买须知选项卡的位置(固定在顶部还是正常)

    CSS: <div id="details" ref="details" class="details" :class="t ...

  10. ckeditor从word粘贴图片

    自动导入Word图片,或者粘贴Word内容时自动上传所有的图片,并且最终保留Word样式,这应该是Web编辑器里面最基本的一个需求功能了.一般情况下我们将Word内容粘贴到Web编辑器(富文本编辑器) ...