mirror of
https://gitee.com/ElemeFE/element.git
synced 2024-11-30 03:07:36 +08:00
update dialog
This commit is contained in:
parent
82b4582c7e
commit
ca59b21011
@ -60,96 +60,106 @@
|
||||
|
||||
## 基本用法
|
||||
|
||||
<el-button :plain="true" v-on:click="dialogVisible = true">点击打开 Dialog</el-button>
|
||||
<el-button :plain="true" v-on:click.native="dialogVisible = true">点击打开 Dialog</el-button>
|
||||
|
||||
<div class="demo-box demo-dialog">
|
||||
<el-dialog title="提示" :visible.sync="dialogVisible">
|
||||
<el-dialog title="提示" :visible="dialogVisible" @open="dialogVisible = true" @close="dialogVisible = false">
|
||||
<span>这是一段信息,这是一段信息,这是一段信息,这是一段信息,这是一段信息,这是一段信息,这是一段信息,这是一段信息</span>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="dialogVisible = false">确 定</el-button>
|
||||
<el-button @click.native="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click.native="dialogVisible = false">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</div>
|
||||
|
||||
```html
|
||||
<el-button :plain="true" v-on:click="openDialog">点击打开 Dialog</el-button>
|
||||
<el-button :plain="true" v-on:click.native="dialogVisible = true">点击打开 Dialog</el-button>
|
||||
|
||||
<el-dialog title="提示" :visible.sync="dialogVisible">
|
||||
<el-dialog title="提示" :visible="dialogVisible" @open="dialogVisible = true" @close="dialogVisible = false">
|
||||
<span>这是一段信息,这是一段信息,这是一段信息,这是一段信息,这是一段信息,这是一段信息,这是一段信息,这是一段信息</span>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="dialogVisible = false">确 定</el-button>
|
||||
<el-button @click.native="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click.native="dialogVisible = false">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
```
|
||||
|
||||
## 设置尺寸
|
||||
|
||||
<el-button :plain="true" v-on:click="dialogTinyVisible = true">点击打开小尺寸 Dialog</el-button>
|
||||
<el-button :plain="true" v-on:click.native="dialogTinyVisible = true">点击打开小尺寸 Dialog</el-button>
|
||||
|
||||
<div class="demo-box demo-dialog">
|
||||
<el-dialog title="提示" :visible.sync="dialogTinyVisible" size="tiny">
|
||||
<el-dialog title="提示" :visible="dialogTinyVisible" size="tiny" @open="dialogTinyVisible = true" @close="dialogTinyVisible = false">
|
||||
<span>这是一段内容</span>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogTinyVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="dialogTinyVisible = false">确 定</el-button>
|
||||
<el-button @click.native="dialogTinyVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click.native="dialogTinyVisible = false">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</div>
|
||||
|
||||
```html
|
||||
<el-button :plain="true" v-on:click="dialogTinyVisible = true">点击打开小尺寸 Dialog</el-button>
|
||||
<el-button :plain="true" v-on:click.native="dialogTinyVisible = true">点击打开小尺寸 Dialog</el-button>
|
||||
|
||||
<el-dialog title="提示" :visible.sync="dialogTinyVisible" size="tiny">
|
||||
<el-dialog title="提示" :visible="dialogTinyVisible" size="tiny" @open="dialogTinyVisible = true" @close="dialogTinyVisible = false">
|
||||
<span>这是一段内容</span>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogTinyVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="dialogTinyVisible = false">确 定</el-button>
|
||||
<el-button @click.native="dialogTinyVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click.native="dialogTinyVisible = false">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
```
|
||||
|
||||
<el-button v-on:click="dialogFullVisible = true">点击打开全屏幕 Dialog</el-button>
|
||||
<el-button v-on:click.native="dialogFullVisible = true">点击打开全屏幕 Dialog</el-button>
|
||||
|
||||
<div class="demo-box demo-dialog">
|
||||
<el-dialog title="提示" :visible.sync="dialogFullVisible" size="full">
|
||||
<el-dialog title="提示" :visible="dialogFullVisible" size="full" @open="dialogFullVisible = true" @close="dialogFullVisible = false">
|
||||
<img src="http://placekitten.com/1920/1280" class="full-image">
|
||||
</el-dialog>
|
||||
</div>
|
||||
|
||||
```html
|
||||
<el-button v-on:click="dialogFullVisible = true">点击打开全屏幕 Dialog</el-button>
|
||||
<el-button v-on:click.native="dialogFullVisible = true">点击打开全屏幕 Dialog</el-button>
|
||||
|
||||
<el-dialog title="提示" :visible.sync="dialogFullVisible" size="full">
|
||||
<el-dialog title="提示" :visible="dialogFullVisible" size="full" @open="dialogFullVisible = true" @close="dialogFullVisible = false">
|
||||
<img src="http://placekitten.com/1920/1280">
|
||||
</el-dialog>
|
||||
```
|
||||
|
||||
## 设置能否通过点击modal或按下esc关闭dialog
|
||||
|
||||
<el-button v-on:click="dialogStubbornVisible = true">打开 Dialog,点击 modal 或按下 esc 关闭无法将其关闭</el-button>
|
||||
<el-button v-on:click.native="dialogStubbornVisible = true">打开 Dialog,点击 modal 或按下 esc 关闭无法将其关闭</el-button>
|
||||
|
||||
<div class="demo-box demo-dialog">
|
||||
<el-dialog title="提示" :visible.sync="dialogStubbornVisible" :close-on-click-modal="false" :close-on-press-escape="false">
|
||||
<el-dialog title="提示"
|
||||
:visible="dialogStubbornVisible"
|
||||
@open="dialogStubbornVisible = true"
|
||||
@close="dialogStubbornVisible = false"
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="false">
|
||||
<span>这是一段信息,这是一段信息,这是一段信息,这是一段信息,这是一段信息,这是一段信息,这是一段信息,这是一段信息</span>
|
||||
</el-dialog>
|
||||
</div>
|
||||
|
||||
```html
|
||||
<el-button v-on:click="dialogStubbornVisible = true">打开 Dialog,点击 modal 或按下 esc 关闭无法将其关闭</el-button>
|
||||
<el-button v-on:click.native="dialogStubbornVisible = true">打开 Dialog,点击 modal 或按下 esc 关闭无法将其关闭</el-button>
|
||||
|
||||
<el-dialog title="提示" :visible.sync="dialogStubbornVisible" :close-on-click-modal="false" :close-on-press-escape="false">
|
||||
<el-dialog title="提示"
|
||||
:visible="dialogStubbornVisible"
|
||||
@open="dialogStubbornVisible = true"
|
||||
@close="dialogStubbornVisible = false"
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="false">
|
||||
<span>这是一段信息,这是一段信息,这是一段信息,这是一段信息,这是一段信息,这是一段信息,这是一段信息,这是一段信息</span>
|
||||
</el-dialog>
|
||||
```
|
||||
|
||||
## 自定义内容
|
||||
|
||||
<el-button v-on:click="dialogTableVisible = true">打开嵌套表格的 Dialog</el-button>
|
||||
<el-button v-on:click.native="dialogTableVisible = true">打开嵌套表格的 Dialog</el-button>
|
||||
|
||||
<div class="demo-box demo-dialog">
|
||||
<el-dialog title="收货地址" :visible.sync="dialogTableVisible">
|
||||
<el-dialog title="收货地址" :visible="dialogTableVisible" @open="dialogTableVisible = true" @close="dialogTableVisible = false">
|
||||
<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>
|
||||
@ -158,10 +168,10 @@
|
||||
</el-dialog>
|
||||
</div>
|
||||
|
||||
<el-button v-on:click="dialogFormVisible = true">打开嵌套表单的 Dialog</el-button>
|
||||
<el-button v-on:click.native="dialogFormVisible = true">打开嵌套表单的 Dialog</el-button>
|
||||
|
||||
<div class="demo-box demo-dialog">
|
||||
<el-dialog title="收货地址" :visible.sync="dialogFormVisible">
|
||||
<el-dialog title="收货地址" :visible="dialogFormVisible" @open="dialogFormVisible = true" @close="dialogFormVisible = false">
|
||||
<el-form :models="form" v-ref:form>
|
||||
<el-form-item label="活动名称" :label-width="formLabelWidth">
|
||||
<el-input :model.sync="form.name" auto-complete="off"></el-input>
|
||||
@ -174,16 +184,16 @@
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogFormVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="dialogFormVisible = false">确 定</el-button>
|
||||
<el-button @click.native="dialogFormVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click.native="dialogFormVisible = false">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</div>
|
||||
|
||||
```html
|
||||
<el-button v-on:click="dialogTableVisible = true">打开嵌套表格的 Dialog</el-button>
|
||||
<el-button v-on:click.native="dialogTableVisible = true">打开嵌套表格的 Dialog</el-button>
|
||||
|
||||
<el-dialog title="收货地址" :visible.sync="dialogTableVisible">
|
||||
<el-dialog title="收货地址" :visible="dialogTableVisible" @open="dialogTableVisible = true" @close="dialogTableVisible = false">
|
||||
<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>
|
||||
@ -191,9 +201,9 @@
|
||||
</el-table>
|
||||
</el-dialog>
|
||||
|
||||
<el-button v-on:click="dialogFormVisible = true">打开嵌套表单的 Dialog</el-button>
|
||||
<el-button v-on:click.native="dialogFormVisible = true">打开嵌套表单的 Dialog</el-button>
|
||||
|
||||
<el-dialog title="收货地址" :visible.sync="dialogFormVisible">
|
||||
<el-dialog title="收货地址" :visible="dialogFormVisible" @open="dialogFormVisible = true" @close="dialogFormVisible = false">
|
||||
<el-form :models="form" v-ref:form>
|
||||
<el-form-item label="活动名称" :label-width="formLabelWidth">
|
||||
<el-input :model.sync="form.name" auto-complete="off"></el-input>
|
||||
@ -206,8 +216,8 @@
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogFormVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="dialogFormVisible = false">确 定</el-button>
|
||||
<el-button @click.native="dialogFormVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click.native="dialogFormVisible = false">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
```
|
||||
|
@ -47,7 +47,7 @@
|
||||
"vue": "^2.0.0-beta.5",
|
||||
"vue-loader": "^9.2.3",
|
||||
"vue-markdown-loader": "^0.4.0",
|
||||
"vue-popup": "^0.1.8",
|
||||
"vue-popup": "^0.2.0",
|
||||
"vue-router": "^2.0.0-beta.2"
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,6 @@
|
||||
"author": "elemefe",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"vue-popup": "^0.1.8"
|
||||
"vue-popup": "^0.2.0"
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
<template>
|
||||
<div class="el-dialog__wrapper" v-if="visible" transition="dialog-fade" @click.self="handleWrapperClick">
|
||||
<div class="el-dialog" :class="[sizeClass, customClass]" v-el:dialog :style="{ 'margin-bottom': size !== 'full' ? '50px' : '', 'top': size !== 'full' ? dynamicTop + 'px' : '0' }">
|
||||
<transition name="dialog-fade">
|
||||
<div class="el-dialog__wrapper" v-show="visible" @click.self="handleWrapperClick">
|
||||
<div class="el-dialog" :class="[sizeClass, customClass]" ref="dialog" :style="{ 'margin-bottom': size !== 'full' ? '50px' : '', 'top': size !== 'full' ? dynamicTop + 'px' : '0' }">
|
||||
<div class="el-dialog__header">
|
||||
<span class="el-dialog__title">{{title}}</span>
|
||||
<div class="el-dialog__headerbtn">
|
||||
@ -8,9 +9,12 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="el-dialog__body"><slot></slot></div>
|
||||
<div class="el-dialog__footer">
|
||||
<slot name="footer"></slot>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</transition>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@ -60,9 +64,14 @@
|
||||
},
|
||||
|
||||
watch: {
|
||||
visible(val) {
|
||||
computedVisible(val) {
|
||||
if (val) {
|
||||
this.$els.dialog.scrollTop = 0;
|
||||
this.$emit('open');
|
||||
this.$nextTick(() => {
|
||||
this.$refs.dialog.scrollTop = 0;
|
||||
});
|
||||
} else {
|
||||
this.$emit('close');
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -76,7 +85,7 @@
|
||||
methods: {
|
||||
handleWrapperClick() {
|
||||
if (this.closeOnClickModal) {
|
||||
this.visible = false;
|
||||
this.computedVisible = false;
|
||||
}
|
||||
},
|
||||
|
||||
@ -85,7 +94,7 @@
|
||||
}
|
||||
},
|
||||
|
||||
ready() {
|
||||
mounted() {
|
||||
if (this.visible) {
|
||||
this.rendered = true;
|
||||
this.open();
|
||||
|
@ -8,7 +8,6 @@
|
||||
position: relative;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
overflow: hidden;
|
||||
background: #fff;
|
||||
border-radius: 2px;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
|
||||
@ -69,20 +68,18 @@
|
||||
float: right;
|
||||
}
|
||||
|
||||
& *[slot=footer] {
|
||||
@e footer {
|
||||
padding: 10px 20px 15px;
|
||||
text-align: right;
|
||||
width: 100%;
|
||||
display: block;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
}
|
||||
|
||||
.dialog-fade-enter {
|
||||
.dialog-fade-enter-active {
|
||||
animation: dialog-fade-in .3s;
|
||||
}
|
||||
|
||||
.dialog-fade-leave {
|
||||
.dialog-fade-leave-active {
|
||||
animation: dialog-fade-out .3s;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user