|
@@ -11,124 +11,146 @@
|
|
|
.demo-box.demo-alert .el-alert {
|
|
|
margin: 20px 0 0;
|
|
|
}
|
|
|
+
|
|
|
+ .demo-box.demo-alert .el-alert:first-child {
|
|
|
+ margin: 0;
|
|
|
+ }
|
|
|
</style>
|
|
|
|
|
|
## 基本用法
|
|
|
|
|
|
-Alert 组件提供四种主题,由`type`属性指定,默认值为`info`,下面的示例展示了四种不同的主题。
|
|
|
-
|
|
|
-<div class="demo-box demo-alert">
|
|
|
- <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>
|
|
|
-</div>
|
|
|
-
|
|
|
+::: demo Alert 组件提供四种主题,由 `type` 属性指定,默认值为 `info`。
|
|
|
```html
|
|
|
-<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>
|
|
|
+ <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`事件来设置关闭时的回调。
|
|
|
-
|
|
|
-下面的示例展示了上述三种情况:
|
|
|
-
|
|
|
-<div class="demo-box demo-alert">
|
|
|
- <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>
|
|
|
-</div>
|
|
|
-
|
|
|
+::: demo 在 Alert 组件中,你可以设置是否可关闭,关闭按钮的文本以及关闭时的回调函数。`closable` 属性决定是否可关闭,接受 `boolean`,默认为 `true`。你可以设置 `close-text` 属性来代替右侧的关闭图标,注意:`close-text` 必须为文本。设置 `close` 事件来设置关闭时的回调。
|
|
|
```html
|
|
|
-<el-alert title="不可关闭" 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>
|
|
|
+ <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,这能更有效的向用户展示你的显示意图。
|
|
|
-
|
|
|
-<div class="demo-box demo-alert">
|
|
|
- <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>
|
|
|
-</div>
|
|
|
-
|
|
|
+::: demo 通过设置 `show-icon` 属性来显示 Alert 的 icon,这能更有效的向用户展示你的显示意图。
|
|
|
```html
|
|
|
-<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>
|
|
|
+ <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>
|
|
|
```
|
|
|
+:::
|
|
|
|
|
|
## 带有辅助性文字介绍
|
|
|
|
|
|
-除了必填的`title`属性外,你可以设置`description`属性来帮助你更好的介绍,我们称之为辅助性文字。辅助性文字只能存放单行文本,会自动换行显示。
|
|
|
-
|
|
|
-<div class="demo-box demo-alert">
|
|
|
- <el-alert title="带辅助性文字介绍" type="success" description="这是一句绕口令:黑灰化肥会挥发发灰黑化肥挥发;灰黑化肥会挥发发黑灰化肥发挥。 黑灰化肥会挥发发灰黑化肥黑灰挥发化为灰……"></el-alert>
|
|
|
-</div>
|
|
|
-
|
|
|
+::: demo 除了必填的 `title` 属性外,你可以设置 `description` 属性来帮助你更好的介绍,我们称之为辅助性文字。辅助性文字只能存放单行文本,会自动换行显示。
|
|
|
```html
|
|
|
-<el-alert
|
|
|
- title="带辅助性文字介绍"
|
|
|
- type="success"
|
|
|
- description="这是一句绕口令:黑灰化肥会挥发发灰黑化肥挥发;灰黑化肥会挥发发黑灰化肥发挥。 黑灰化肥会挥发发灰黑化肥黑灰挥发化为灰……">
|
|
|
-</el-alert>
|
|
|
+<template>
|
|
|
+ <el-alert
|
|
|
+ title="带辅助性文字介绍"
|
|
|
+ type="success"
|
|
|
+ description="这是一句绕口令:黑灰化肥会挥发发灰黑化肥挥发;灰黑化肥会挥发发黑灰化肥发挥。 黑灰化肥会挥发发灰黑化肥黑灰挥发化为灰……">
|
|
|
+ </el-alert>
|
|
|
+</template>
|
|
|
```
|
|
|
+:::
|
|
|
|
|
|
## 带有 icon 和辅助性文字介绍
|
|
|
|
|
|
-最后,这是一个同时具有 icon 和辅助性文字的样例。
|
|
|
-
|
|
|
-<div class="demo-box demo-alert">
|
|
|
- <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>
|
|
|
-</div>
|
|
|
-
|
|
|
+::: demo 最后,这是一个同时具有 icon 和辅助性文字的样例。
|
|
|
```html
|
|
|
-<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>
|
|
|
+ <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
|
|
|
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|