2020-07-28 10:03:53 +08:00
|
|
|
---
|
|
|
|
title: Alert 提示
|
2020-07-29 16:20:21 +08:00
|
|
|
description:
|
2020-07-28 10:03:53 +08:00
|
|
|
type: 0
|
|
|
|
group: ⚙ 组件
|
|
|
|
menuName: Alert 提示
|
2020-07-29 16:20:21 +08:00
|
|
|
icon:
|
2020-07-28 10:03:53 +08:00
|
|
|
order: 27
|
|
|
|
---
|
2020-07-29 16:20:21 +08:00
|
|
|
|
2020-07-28 10:03:53 +08:00
|
|
|
用来做文字特殊提示,分为四类:提示类、成功类、警告类和危险类。
|
|
|
|
|
|
|
|
## 基本使用
|
|
|
|
|
2021-11-24 21:44:38 +08:00
|
|
|
`level`属性支持 4 种预设样式:`info`, `success`, `warning`, `danger`。
|
|
|
|
|
2021-01-07 23:35:03 +08:00
|
|
|
```schema: scope="body"
|
2020-07-28 10:03:53 +08:00
|
|
|
[
|
|
|
|
{
|
|
|
|
"type": "alert",
|
2021-11-24 21:44:38 +08:00
|
|
|
"body": "提示类文案",
|
|
|
|
"level": "info",
|
|
|
|
"className": "mb-1"
|
2020-07-28 10:03:53 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "alert",
|
2021-11-24 21:44:38 +08:00
|
|
|
"title": "提示类标题",
|
|
|
|
"body": "提示类文案",
|
|
|
|
"level": "info",
|
|
|
|
"className": "mb-3"
|
2020-07-28 10:03:53 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "alert",
|
2021-11-24 21:44:38 +08:00
|
|
|
"body": "成功类文案",
|
|
|
|
"level": "success",
|
|
|
|
"className": "mb-1"
|
2020-07-28 10:03:53 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "alert",
|
2021-11-24 21:44:38 +08:00
|
|
|
"title": "成功类标题",
|
|
|
|
"body": "成功类文案",
|
|
|
|
"level": "success",
|
|
|
|
"className": "mb-3"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "alert",
|
|
|
|
"body": "警告类文案",
|
|
|
|
"level": "warning",
|
|
|
|
"className": "mb-1"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "alert",
|
|
|
|
"title": "警告类标题",
|
|
|
|
"body": "警告类文案",
|
|
|
|
"level": "warning",
|
|
|
|
"className": "mb-3"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "alert",
|
|
|
|
"body": "危险类文案",
|
|
|
|
"level": "danger",
|
|
|
|
"className": "mb-1"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "alert",
|
|
|
|
"title": "危险类标题",
|
|
|
|
"body": "危险类文案",
|
|
|
|
"level": "danger",
|
|
|
|
},
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
|
|
|
## 图标
|
|
|
|
|
|
|
|
配置`"showIcon": true`后展示图标让信息更加醒目。可以通过`icon`属性自定义设置 icon 内容,如果`icon`属性为空,则根据`level`值添加默认 icon。
|
|
|
|
|
|
|
|
```schema: scope="body"
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"type": "alert",
|
|
|
|
"body": "提示类文案",
|
|
|
|
"level": "info",
|
|
|
|
"showIcon": true,
|
|
|
|
"className": "mb-1"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "alert",
|
|
|
|
"title": "提示类标题",
|
|
|
|
"body": "提示类文案",
|
|
|
|
"level": "info",
|
|
|
|
"showIcon": true,
|
|
|
|
"className": "mb-3"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "alert",
|
|
|
|
"body": "成功类文案",
|
|
|
|
"level": "success",
|
|
|
|
"showIcon": true,
|
|
|
|
"className": "mb-1"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "alert",
|
|
|
|
"title": "成功类标题",
|
|
|
|
"body": "成功类文案",
|
|
|
|
"level": "success",
|
|
|
|
"showIcon": true,
|
|
|
|
"className": "mb-3"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "alert",
|
|
|
|
"body": "警告类文案",
|
|
|
|
"level": "warning",
|
|
|
|
"showIcon": true,
|
|
|
|
"className": "mb-1"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "alert",
|
|
|
|
"title": "警告类标题",
|
|
|
|
"body": "警告类文案",
|
|
|
|
"level": "warning",
|
|
|
|
"showIcon": true,
|
|
|
|
"className": "mb-3"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "alert",
|
|
|
|
"body": "危险类文案",
|
|
|
|
"level": "danger",
|
|
|
|
"showIcon": true,
|
|
|
|
"className": "mb-1"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "alert",
|
|
|
|
"title": "危险类标题",
|
|
|
|
"body": "危险类文案",
|
|
|
|
"level": "danger",
|
|
|
|
"showIcon": true,
|
|
|
|
"className": "mb-3"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "alert",
|
|
|
|
"body": "自定义ICON文案",
|
|
|
|
"showIcon": true,
|
2022-03-02 12:06:09 +08:00
|
|
|
"icon": "info-circle",
|
2021-11-24 21:44:38 +08:00
|
|
|
"className": "mb-1"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "alert",
|
|
|
|
"title": "自定义ICON标题",
|
|
|
|
"body": "自定义ICON文案",
|
|
|
|
"showIcon": true,
|
2022-03-02 12:06:09 +08:00
|
|
|
"icon": "fa fa-list"
|
|
|
|
}
|
2020-07-28 10:03:53 +08:00
|
|
|
]
|
|
|
|
```
|
|
|
|
|
2022-01-28 12:40:06 +08:00
|
|
|
## level 支持表达式
|
|
|
|
|
|
|
|
> 1.6.4 及以上版本
|
|
|
|
|
|
|
|
修改下面例子的 status 值为 2 就能看到变化
|
|
|
|
|
|
|
|
```schema:
|
|
|
|
{
|
|
|
|
"type": "page",
|
|
|
|
"data": {
|
|
|
|
"status": 1
|
|
|
|
},
|
|
|
|
"body": [
|
|
|
|
{
|
|
|
|
"type": "alert",
|
|
|
|
"level": "${IFS(status===1, 'danger', status===2, 'warning')}",
|
|
|
|
"body": "这是内容区"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
同时 icon 和 showIcon 也都支持表达式
|
|
|
|
|
2020-07-28 10:03:53 +08:00
|
|
|
## 显示关闭按钮
|
|
|
|
|
|
|
|
配置`"showCloseButton": true`实现显示关闭按钮。
|
|
|
|
|
2021-01-07 23:35:03 +08:00
|
|
|
```schema: scope="body"
|
2020-07-28 10:03:53 +08:00
|
|
|
[
|
|
|
|
{
|
|
|
|
"type": "alert",
|
2021-11-24 21:44:38 +08:00
|
|
|
"body": "显示关闭按钮的提示",
|
|
|
|
"level": "info",
|
|
|
|
"showCloseButton": true,
|
|
|
|
"showIcon": true,
|
|
|
|
"className": "mb-2"
|
2020-07-28 10:03:53 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "alert",
|
2021-11-24 21:44:38 +08:00
|
|
|
"title": "可关闭提示",
|
2020-07-28 10:03:53 +08:00
|
|
|
"body": "显示关闭按钮的提示",
|
2021-11-24 21:44:38 +08:00
|
|
|
"level": "success",
|
|
|
|
"showCloseButton": true,
|
|
|
|
"showIcon": true
|
2020-07-28 10:03:53 +08:00
|
|
|
}
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
2023-11-15 20:45:05 +08:00
|
|
|
## 操作区域
|
|
|
|
|
|
|
|
> `3.6.0`及以上版本
|
|
|
|
|
|
|
|
配置`actions`属性,可以添加操作区域。
|
|
|
|
|
|
|
|
```schema: scope="body"
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"type": "alert",
|
|
|
|
"level": "success",
|
|
|
|
"className": "mb-3",
|
|
|
|
"showIcon": true,
|
|
|
|
"showCloseButton": true,
|
|
|
|
"title": "标题",
|
|
|
|
"body": "创建成功",
|
|
|
|
"actions": [
|
|
|
|
{
|
|
|
|
"type": "button",
|
|
|
|
"label": "查看详情",
|
|
|
|
"size": "xs",
|
|
|
|
"level": "link",
|
|
|
|
"style": {
|
|
|
|
"position": "relative",
|
|
|
|
"top": "25px",
|
|
|
|
"left": "30px"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "alert",
|
|
|
|
"level": "info",
|
|
|
|
"showIcon": true,
|
|
|
|
"showCloseButton": true,
|
|
|
|
"body": "创建成功",
|
|
|
|
"actions": {
|
|
|
|
"type": "flex",
|
|
|
|
"justify": "flex-start",
|
|
|
|
"alignItems": "flex-start",
|
|
|
|
"direction": "column",
|
|
|
|
"style": {"padding": "6px"},
|
|
|
|
"items": [
|
|
|
|
{
|
|
|
|
"type": "button",
|
|
|
|
"label": "详情",
|
|
|
|
"size": "xs",
|
|
|
|
"level": "primary",
|
|
|
|
"style": {
|
|
|
|
"marginBottom": "5px"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "button",
|
|
|
|
"label": "关闭",
|
|
|
|
"size": "xs",
|
|
|
|
"level": "danger"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
2020-07-28 10:03:53 +08:00
|
|
|
## 属性表
|
|
|
|
|
2023-11-15 20:45:05 +08:00
|
|
|
| 属性名 | 类型 | 默认值 | 说明 | 版本 |
|
|
|
|
| -------------------- | ----------------------------------------- | --------- | -------------------------------------------------------- | --- |
|
2021-11-24 21:44:38 +08:00
|
|
|
| type | `string` | `"alert"` | 指定为 alert 渲染器 |
|
2023-07-27 16:03:30 +08:00
|
|
|
| title | `string` | | alert标题 |
|
2021-11-24 21:44:38 +08:00
|
|
|
| className | `string` | | 外层 Dom 的类名 |
|
|
|
|
| level | `string` | `info` | 级别,可以是:`info`、`success`、`warning` 或者 `danger` |
|
2023-11-15 20:45:05 +08:00
|
|
|
| body | [`SchemaNode[] \| SchemaNode`](../../docs/types/schemanode) | | 显示内容 |
|
2021-11-24 21:44:38 +08:00
|
|
|
| showCloseButton | `boolean` | `false` | 是否显示关闭按钮 |
|
|
|
|
| closeButtonClassName | `string` | | 关闭按钮的 CSS 类名 |
|
|
|
|
| showIcon | `boolean` | `false` | 是否显示 icon |
|
|
|
|
| icon | `string` | | 自定义 icon |
|
|
|
|
| iconClassName | `string` | | icon 的 CSS 类名 |
|
2023-11-15 20:45:05 +08:00
|
|
|
| actions | [`SchemaNode[] \| SchemaNode`](../../docs/types/schemanode) | | 操作区域 | `3.6.0` |
|