|
@@ -19,9 +19,11 @@
|
|
name: '王小虎',
|
|
name: '王小虎',
|
|
address: '上海市普陀区金沙江路 1518 弄'
|
|
address: '上海市普陀区金沙江路 1518 弄'
|
|
}],
|
|
}],
|
|
- dialogVisible: false,
|
|
|
|
|
|
+ dialogVisible: true,
|
|
dialogTableVisible: false,
|
|
dialogTableVisible: false,
|
|
dialogFormVisible: false,
|
|
dialogFormVisible: false,
|
|
|
|
+ outerVisible: false,
|
|
|
|
+ innerVisible: false,
|
|
form: {
|
|
form: {
|
|
name: '',
|
|
name: '',
|
|
region: '',
|
|
region: '',
|
|
@@ -76,7 +78,7 @@
|
|
|
|
|
|
Dialog 弹出一个对话框,适合需要定制性更大的场景。
|
|
Dialog 弹出一个对话框,适合需要定制性更大的场景。
|
|
|
|
|
|
-:::demo 需要设置`visible`属性,它接收`Boolean`,当为`true`时显示 Dialog。Dialog 分为两个部分:`body`和`footer`,`footer`需要具名为`footer`的`slot`。`title`属性用于定义标题,它是可选的,默认值为空。最后,本例还展示了`beforeClose`的用法。
|
|
|
|
|
|
+:::demo 需要设置`visible`属性,它接收`Boolean`,当为`true`时显示 Dialog。Dialog 分为两个部分:`body`和`footer`,`footer`需要具名为`footer`的`slot`。`title`属性用于定义标题,它是可选的,默认值为空。最后,本例还展示了`before-close`的用法。
|
|
|
|
|
|
```html
|
|
```html
|
|
<el-button type="text" @click="dialogVisible = true">点击打开 Dialog</el-button>
|
|
<el-button type="text" @click="dialogVisible = true">点击打开 Dialog</el-button>
|
|
@@ -84,7 +86,7 @@ Dialog 弹出一个对话框,适合需要定制性更大的场景。
|
|
<el-dialog
|
|
<el-dialog
|
|
title="提示"
|
|
title="提示"
|
|
:visible.sync="dialogVisible"
|
|
:visible.sync="dialogVisible"
|
|
- size="tiny"
|
|
|
|
|
|
+ width="30%"
|
|
:before-close="handleClose">
|
|
:before-close="handleClose">
|
|
<span>这是一段信息</span>
|
|
<span>这是一段信息</span>
|
|
<span slot="footer" class="dialog-footer">
|
|
<span slot="footer" class="dialog-footer">
|
|
@@ -114,6 +116,10 @@ Dialog 弹出一个对话框,适合需要定制性更大的场景。
|
|
```
|
|
```
|
|
:::
|
|
:::
|
|
|
|
|
|
|
|
+:::tip
|
|
|
|
+`before-close` 仅当用户通过点击关闭图标或遮罩关闭 Dialog 时起效。如果你在 `footer` 具名 slot 里添加了用于关闭 Dialog 的按钮,那么可以在按钮的点击回调函数里加入 `before-close` 的相关逻辑。
|
|
|
|
+:::
|
|
|
|
+
|
|
### 自定义内容
|
|
### 自定义内容
|
|
|
|
|
|
Dialog 组件的内容可以是任意的,甚至可以是表格或表单,下面是应用了 Element Table 和 Form 组件的两个样例。
|
|
Dialog 组件的内容可以是任意的,甚至可以是表格或表单,下面是应用了 Element Table 和 Form 组件的两个样例。
|
|
@@ -134,7 +140,7 @@ Dialog 组件的内容可以是任意的,甚至可以是表格或表单,下
|
|
<!-- Form -->
|
|
<!-- Form -->
|
|
<el-button type="text" @click="dialogFormVisible = true">打开嵌套表单的 Dialog</el-button>
|
|
<el-button type="text" @click="dialogFormVisible = true">打开嵌套表单的 Dialog</el-button>
|
|
|
|
|
|
-<el-dialog title="收货地址" :visible.sync="dialogFormVisible">
|
|
|
|
|
|
+<el-dialog title="收货地址" :visible.sync="dialogFormVisible" fullscreen>
|
|
<el-form :model="form">
|
|
<el-form :model="form">
|
|
<el-form-item label="活动名称" :label-width="formLabelWidth">
|
|
<el-form-item label="活动名称" :label-width="formLabelWidth">
|
|
<el-input v-model="form.name" auto-complete="off"></el-input>
|
|
<el-input v-model="form.name" auto-complete="off"></el-input>
|
|
@@ -193,15 +199,55 @@ Dialog 组件的内容可以是任意的,甚至可以是表格或表单,下
|
|
```
|
|
```
|
|
:::
|
|
:::
|
|
|
|
|
|
|
|
+### 嵌套的 Dialog
|
|
|
|
+如果需要在一个 Dialog 内部嵌套另一个 Dialog,需要使用 `append-to-body` 属性。
|
|
|
|
+:::demo 正常情况下,我们不建议使用嵌套的 Dialog,如果需要在页面上同时显示多个 Dialog,可以将它们平级放置。对于确实需要嵌套 Dialog 的场景,我们提供了`append-to-body`属性。将内层 Dialog 的该属性设置为 true,它就会插入至 body 元素上,从而保证内外层 Dialog 和遮罩层级关系的正确。
|
|
|
|
+```html
|
|
|
|
+<template>
|
|
|
|
+ <el-button type="text" @click="outerVisible = true">点击打开外层 Dialog</el-button>
|
|
|
|
+
|
|
|
|
+ <el-dialog title="外层 Dialog" :visible.sync="outerVisible">
|
|
|
|
+ <el-dialog
|
|
|
|
+ width="30%"
|
|
|
|
+ title="内层 Dialog"
|
|
|
|
+ :visible.sync="innerVisible"
|
|
|
|
+ append-to-body>
|
|
|
|
+ </el-dialog>
|
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
|
+ <el-button @click="outerVisible = false">取 消</el-button>
|
|
|
|
+ <el-button type="primary" @click="innerVisible = true">打开内层 Dialog</el-button>
|
|
|
|
+ </div>
|
|
|
|
+ </el-dialog>
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<script>
|
|
|
|
+ export default {
|
|
|
|
+ data() {
|
|
|
|
+ return {
|
|
|
|
+ outerVisible: false,
|
|
|
|
+ innerVisible: false
|
|
|
|
+ };
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+</script>
|
|
|
|
+```
|
|
|
|
+:::
|
|
|
|
+
|
|
|
|
+:::tip
|
|
|
|
+如果 `visible` 属性绑定的变量位于 Vuex 的 store 内,那么 `.sync` 不会正常工作。此时需要去除 `.sync` 修饰符,同时监听 Dialog 的 `open` 和 `close` 事件,在事件回调中执行 Vuex 中对应的 mutation 更新 `visible` 属性绑定的变量的值。
|
|
|
|
+:::
|
|
|
|
+
|
|
### Attributes
|
|
### Attributes
|
|
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|
|
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|
|
|---------- |-------------- |---------- |-------------------------------- |-------- |
|
|
|---------- |-------------- |---------- |-------------------------------- |-------- |
|
|
| visible | 是否显示 Dialog,支持 .sync 修饰符 | boolean | — | false |
|
|
| visible | 是否显示 Dialog,支持 .sync 修饰符 | boolean | — | false |
|
|
| title | Dialog 的标题,也可通过具名 slot (见下表)传入 | string | — | — |
|
|
| title | Dialog 的标题,也可通过具名 slot (见下表)传入 | string | — | — |
|
|
-| size | Dialog 的大小 | string | tiny/small/large/full | small |
|
|
|
|
-| top | Dialog CSS 中的 top 值(仅在 size 不为 full 时有效) | string | — | 15% |
|
|
|
|
|
|
+| width | Dialog 的宽度 | string | — | 50% |
|
|
|
|
+| fullscreen | 是否为全屏 Dialog | boolean | — | false |
|
|
|
|
+| top | Dialog CSS 中的 margin-top 值(仅在 size 不为 full 时有效) | string | — | 15vh |
|
|
| modal | 是否需要遮罩层 | boolean | — | true |
|
|
| modal | 是否需要遮罩层 | boolean | — | true |
|
|
| modal-append-to-body | 遮罩层是否插入至 body 元素上,若为 false,则遮罩层会插入至 Dialog 的父元素上 | boolean | — | true |
|
|
| modal-append-to-body | 遮罩层是否插入至 body 元素上,若为 false,则遮罩层会插入至 Dialog 的父元素上 | boolean | — | true |
|
|
|
|
+| append-to-body | Dialog 自身是否插入至 body 元素上。嵌套的 Dialog 必须指定该属性并赋值为 true | boolean | — | false |
|
|
| lock-scroll | 是否在 Dialog 出现时将 body 滚动锁定 | boolean | — | true |
|
|
| lock-scroll | 是否在 Dialog 出现时将 body 滚动锁定 | boolean | — | true |
|
|
| custom-class | Dialog 的自定义类名 | string | — | — |
|
|
| custom-class | Dialog 的自定义类名 | string | — | — |
|
|
| close-on-click-modal | 是否可以通过点击 modal 关闭 Dialog | boolean | — | true |
|
|
| close-on-click-modal | 是否可以通过点击 modal 关闭 Dialog | boolean | — | true |
|