2016-07-27 14:15:02 +08:00
|
|
|
|
<script>
|
|
|
|
|
module.exports = {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
gridData: [{
|
|
|
|
|
date: '2016-05-02',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄'
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-04',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄'
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-01',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄'
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-03',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄'
|
|
|
|
|
}],
|
|
|
|
|
dialogVisible: false,
|
|
|
|
|
dialogTinyVisible: false,
|
|
|
|
|
dialogFullVisible: false,
|
|
|
|
|
dialogStubbornVisible: false,
|
|
|
|
|
dialogTableVisible: false,
|
2016-08-19 14:45:08 +08:00
|
|
|
|
dialogBindVisible: false,
|
2016-07-27 14:15:02 +08:00
|
|
|
|
dialogFormVisible: false,
|
|
|
|
|
form: {
|
|
|
|
|
name: '',
|
|
|
|
|
region: '',
|
|
|
|
|
date1: '',
|
|
|
|
|
date2: '',
|
|
|
|
|
delivery: false,
|
|
|
|
|
type: [],
|
|
|
|
|
resource: '',
|
|
|
|
|
desc: ''
|
|
|
|
|
},
|
|
|
|
|
formLabelWidth: '80px'
|
|
|
|
|
};
|
2016-08-19 14:45:08 +08:00
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
openDialog() {
|
|
|
|
|
this.$refs.dialogBind.open();
|
|
|
|
|
}
|
2016-07-27 14:15:02 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
.demo-box.demo-dialog {
|
|
|
|
|
.dialog-footer button:first-child {
|
|
|
|
|
margin-right: 10px;
|
|
|
|
|
}
|
|
|
|
|
.full-image {
|
|
|
|
|
width: 100%;
|
|
|
|
|
}
|
|
|
|
|
.el-dialog__wrapper {
|
|
|
|
|
margin: 0;
|
2016-08-19 14:45:08 +08:00
|
|
|
|
}
|
2016-09-14 11:15:28 +08:00
|
|
|
|
.el-select {
|
|
|
|
|
width: 300px;
|
|
|
|
|
}
|
2016-07-27 14:15:02 +08:00
|
|
|
|
.el-input {
|
|
|
|
|
width: 300px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|
2016-08-26 18:34:54 +08:00
|
|
|
|
## Dialog 对话框
|
2016-09-07 18:46:20 +08:00
|
|
|
|
在保留当前页面状态的情况下,告知用户并承载相关操作。
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-26 18:34:54 +08:00
|
|
|
|
### 基本用法
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-09-12 13:53:45 +08:00
|
|
|
|
Dialog 弹出一个对话框,适合需要定制性更大的场景。
|
2016-08-19 14:45:08 +08:00
|
|
|
|
|
2016-09-12 13:53:45 +08:00
|
|
|
|
:::demo 需要设置`v-model`属性,它接收`Boolean`,当为`true`时显示 Dialog。Dialog 分为两个部分:`body`和`footer`,`footer`需要具名为`footer`的`slot`。`title`属性用于定义标题,它是可选的,默认值为空。本例通过显式改变`v-model`的值来打开 Dialog,此外我们还为 Dialog 实例提供了`open`和`close`方法,可以通过调用它们来打开/关闭 Dialog。
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
|
|
|
|
```html
|
2016-08-29 19:01:42 +08:00
|
|
|
|
<el-button type="text" @click.native="dialogVisible = true">点击打开 Dialog</el-button>
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-09-13 20:02:33 +08:00
|
|
|
|
<el-dialog title="提示" v-model="dialogVisible" size="tiny">
|
|
|
|
|
<span>这是一段信息</span>
|
2016-07-27 14:15:02 +08:00
|
|
|
|
<span slot="footer" class="dialog-footer">
|
2016-08-08 13:59:26 +08:00
|
|
|
|
<el-button @click.native="dialogVisible = false">取 消</el-button>
|
|
|
|
|
<el-button type="primary" @click.native="dialogVisible = false">确 定</el-button>
|
2016-07-27 14:15:02 +08:00
|
|
|
|
</span>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
```
|
2016-08-25 18:24:51 +08:00
|
|
|
|
:::
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-26 18:34:54 +08:00
|
|
|
|
### 自定义内容
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-09-12 13:53:45 +08:00
|
|
|
|
Dialog 组件的内容可以是任意的,甚至可以是表格或表单,下面是应用了 Element Table 和 Form 组件的两个样例。
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-25 18:24:51 +08:00
|
|
|
|
:::demo
|
2016-07-27 14:15:02 +08:00
|
|
|
|
```html
|
2016-08-25 18:24:51 +08:00
|
|
|
|
<!-- Table -->
|
2016-08-29 19:01:42 +08:00
|
|
|
|
<el-button type="text" @click.native="dialogTableVisible = true" type="text">打开嵌套表格的 Dialog</el-button>
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-08 17:22:21 +08:00
|
|
|
|
<el-dialog title="收货地址" v-model="dialogTableVisible">
|
2016-07-27 14:15:02 +08:00
|
|
|
|
<el-table :data="gridData">
|
|
|
|
|
<el-table-column property="date" label="日期" width="150"></el-table-column>
|
|
|
|
|
<el-table-column property="name" label="姓名" width="200"></el-table-column>
|
|
|
|
|
<el-table-column property="address" label="地址"></el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
|
2016-08-25 18:24:51 +08:00
|
|
|
|
<!-- Form -->
|
2016-08-29 19:01:42 +08:00
|
|
|
|
<el-button type="text" @click.native="dialogFormVisible = true" type="text">打开嵌套表单的 Dialog</el-button>
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-08 17:22:21 +08:00
|
|
|
|
<el-dialog title="收货地址" v-model="dialogFormVisible">
|
2016-09-06 19:30:50 +08:00
|
|
|
|
<el-form :model="form">
|
2016-07-27 14:15:02 +08:00
|
|
|
|
<el-form-item label="活动名称" :label-width="formLabelWidth">
|
2016-09-02 19:32:17 +08:00
|
|
|
|
<el-input v-model="form.name" auto-complete="off"></el-input>
|
2016-07-27 14:15:02 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="活动区域" :label-width="formLabelWidth">
|
2016-09-02 19:32:17 +08:00
|
|
|
|
<el-select v-model="form.region" placeholder="请选择活动区域">
|
2016-07-27 14:15:02 +08:00
|
|
|
|
<el-option label="区域一" value="shanghai"></el-option>
|
|
|
|
|
<el-option label="区域二" value="beijing"></el-option>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
<span slot="footer" class="dialog-footer">
|
2016-08-08 13:59:26 +08:00
|
|
|
|
<el-button @click.native="dialogFormVisible = false">取 消</el-button>
|
|
|
|
|
<el-button type="primary" @click.native="dialogFormVisible = false">确 定</el-button>
|
2016-07-27 14:15:02 +08:00
|
|
|
|
</span>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
```
|
2016-08-25 18:24:51 +08:00
|
|
|
|
:::
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-26 18:34:54 +08:00
|
|
|
|
### Attributes
|
2016-07-27 14:15:02 +08:00
|
|
|
|
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|
|
|
|
|
|---------- |-------------- |---------- |-------------------------------- |-------- |
|
2016-09-02 13:56:47 +08:00
|
|
|
|
| title | Dialog 的标题 | string | — | — |
|
2016-08-29 19:01:42 +08:00
|
|
|
|
| size | Dialog 的大小 | string | tiny/small/large/full | small |
|
2016-09-02 13:56:47 +08:00
|
|
|
|
| modal | 是否需要遮罩层 | boolean | — | true |
|
2016-10-02 21:14:43 +08:00
|
|
|
|
| lockScroll | 是否在 Dialog 出现时将 body 滚动锁定 | boolean | — | true |
|
2016-09-02 13:56:47 +08:00
|
|
|
|
| custom-class | Dialog 的自定义类名 | string | — | — |
|
|
|
|
|
| close-on-click-modal | 是否可以通过点击 modal 关闭 Dialog | boolean | — | true |
|
|
|
|
|
| close-on-press-escape | 是否可以通过按下 ESC 关闭 Dialog | boolean | — | true |
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-26 18:34:54 +08:00
|
|
|
|
### Slot
|
2016-07-27 14:15:02 +08:00
|
|
|
|
| name | 说明 |
|
|
|
|
|
|------|--------|
|
2016-09-02 13:56:47 +08:00
|
|
|
|
| — | Dialog 的内容 |
|
2016-08-19 14:45:08 +08:00
|
|
|
|
| footer | Dialog 按钮操作区的内容 |
|
2016-08-08 17:22:21 +08:00
|
|
|
|
|
2016-08-26 18:34:54 +08:00
|
|
|
|
### 方法
|
2016-09-07 18:46:20 +08:00
|
|
|
|
每个 `el-dialog` 实例都暴露了如下方法,用于在不显式改变 `v-model` 值的情况下打开 / 关闭实例:
|
2016-08-08 17:22:21 +08:00
|
|
|
|
| 方法名 | 说明 |
|
|
|
|
|
|------|--------|
|
|
|
|
|
| open | 打开当前实例 |
|
|
|
|
|
| close | 关闭当前实例 |
|
2016-10-04 17:44:34 +08:00
|
|
|
|
|
|
|
|
|
### Events
|
|
|
|
|
| 事件名称 | 说明 | 回调参数 |
|
|
|
|
|
|---------- |-------- |---------- |
|
|
|
|
|
| close | Dialog 关闭的回调 | — |
|
|
|
|
|
| open | Dialog 打开的回调 | — |
|