$Modal support SSR

This commit is contained in:
Aresn 2017-06-01 12:32:00 +08:00
parent 24c8f4eaba
commit 77cf1cd573
3 changed files with 148 additions and 55 deletions

View file

@ -1,33 +1,45 @@
<template>
<div>
<Button type="primary" @click="modal1 = true">显示对话框</Button>
<Modal
v-model="modal1"
:title="title"
@on-ok="ok"
:mask-closable="false"
@on-cancel="cancel">
<p><Button type="ghost" @click="title = '这是标题'">设置标题</Button> {{title}}</p>
<p>对话框内容</p>
<p>对话框内容</p>
</Modal>
<Button @click="confirm">标准</Button>
<Button @click="custom">自定义按钮文字</Button>
<Button @click="async">异步关闭</Button>
</div>
</template>
<script>
export default {
data () {
return {
modal1: true,
title:''
}
},
methods: {
ok () {
this.$Message.info('点击了确定');
confirm () {
this.$Modal.confirm({
title: '确认对话框标题',
content: '<p>一些对话框内容</p><p>一些对话框内容</p>',
onOk: () => {
this.$Message.info('点击了确定');
},
onCancel: () => {
this.$Message.info('点击了取消');
}
});
},
cancel () {
this.$Message.info('点击了取消');
custom () {
this.$Modal.confirm({
title: '确认对话框标题',
content: '<p>一些对话框内容</p><p>一些对话框内容</p>',
okText: 'OK',
cancelText: 'Cancel'
});
},
async () {
this.$Modal.confirm({
title: '确认对话框标题',
content: '<p>对话框将在 2秒 后关闭</p>',
loading: true,
onOk: () => {
setTimeout(() => {
this.$Modal.remove();
this.$Message.info('异步关闭了对话框');
}, 2000);
}
});
}
}
}