Alert 警告
基本用法
页面中的非浮层元素,不会自动消失。
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 警告的更多相关文章
- [Swift通天遁地]一、超级工具-(15)使用SCLAlertView制作强大的Alert警告窗口和Input编辑窗口
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...
- alert警告框
标签中写: <div class="alert alert-warning fade in"> <button class="close" d ...
- alert警告框点击确定后自动提交表单
转载于 :https://zhidao.baidu.com/question/619375120140398412.html 在页面中有多个input type="text"的文 ...
- Bootstrap-Plugin:警告框(Alert)插件
ylbtech-Bootstrap-Plugin:警告框(Alert)插件 1.返回顶部 1. Bootstrap 警告框(Alert)插件 警告框(Alert)消息大多是用来向终端用户显示诸如警告或 ...
- Bootstrap历练实例:警告框(Alert)插件事件
事件 下表列出了警告框(Alert)插件中要用到的事件.这些事件可在函数中当钩子使用. 事件 描述 实例 close.bs.alert 当调用 close 实例方法时立即触发该事件. $('#myal ...
- amazeui学习笔记--js插件(UI增强)--警告框Alert
amazeui学习笔记--js插件(UI增强)--警告框Alert 一.总结 1.警告框基本样式:用am-alert声明div容器, <div class="am-alert" ...
- iOS Webview 实现修改javascript confirm 和 alert
贴代码: @interface UIWebView (JavaScriptAlert) -(void) webView:(UIWebView *)sender runJavaScriptAlertPa ...
- 三种对话框的示例(alert,confirm,prompt)
示例代码 <h2>JavaScriptDialog</h2> <hr/> <buttononclick="btn_alert()"> ...
- prmopt 提示框接收字符串,输入后按确定弹出警告框,警告内容为逆序的字符串
虽然已经找到offer,但因为公司还没安排实习,所以在学校的时间多了很多.好吧,这段时间我用来备考四级啦(好悲催,还没过),然后这一天,闲着无聊,就帮妹妹看了这样子一道题目啦. 题目内容: 编制一个从 ...
随机推荐
- git tag 重写
有的时候我们想要在git的master分支中插入一个tag,这个时候就需要我们先删除一个不重要的tag,然后切到我们想要提交内容的地方,重新打tag. 例如:在master分支上修改提交,在commi ...
- UNetbootin安装linux
用u盘安装linux系统,最好的方法莫过于用UNetbootin,网址:http://unetbootin.github.io/ UNetbootin allows you to create boo ...
- vmware 兼容问题
1.出现此问题的原因是Device Guard或Credential Guard与Workstation不兼容.2.Windows系统的Hyper-V不兼容导致.解决方法: 步骤一:禁用Device ...
- 8.CNN应用于手写字识别
import numpy as np from keras.datasets import mnist from keras.utils import np_utils from keras.mode ...
- php的lareval框架配置出错
前两天,在学习php的 lareval 框架时,从官网上下载完lareval的安装包后,按照网上的配置教程一点一点的配置完后,当点击public 文件运行时就出现一个让我很头痛的问题,我自己外加两个大 ...
- AspectJ注解支持
<aop:aspectj-autoproxy/> 配置aspectj启动 AspectJAutoProxyBeanDefintionParser implements BeanDefini ...
- Web.xml 定制URL
直接上xml里的代码: <!--声明有哪些Servlet--> <servlet> <servlet-name>Book</servlet-name> ...
- ESP8266_04管脚控制与软件定时器
ESP8266_04管脚控制与软件定时器 from :https://mp.weixin.qq.com/s/APawDx4io4gKJyOeuErTLA 原创: MCU启航 单片机爱好者 今天 这一节 ...
- Java方法调用机制
最近在编程时,修改方法传入对象的对象引用,并没有将修改反映到调用方法中.奇怪为什么结果没有变化,原因是遗忘了Java对象引用和内存分配机制.本文介绍3个点: ① 该问题举例说明 ② 简要阐述Java内 ...
- c++实例之通讯录管理系统之清空联系人功能(七)
#include<iostream> using namespace std; constexpr auto MAX = ; //联系人结构体 struct Person { string ...