Commit 672a2805ef8bf83031e25e7fcbc49df0a844abe5

Authored by 梁灏
1 parent c2db4f92

fixed #505

Showing 2 changed files with 28 additions and 36 deletions   Show diff stats
examples/routers/modal.vue
1 1 <template>
2 2 <div>
3   - <Button @click="confirm">标准</Button>
4   - <Button @click="custom">自定义按钮文字</Button>
5   - <Button @click="async">异步关闭</Button>
  3 + <Button type="primary" @click="modal1 = true">显示对话框</Button>
  4 + <Modal
  5 + v-model="modal1"
  6 + title="普通的Modal对话框标题"
  7 + :transition-names="['slide-up', 'ease']"
  8 + @on-ok="ok"
  9 + @on-cancel="cancel">
  10 + <p>对话框内容</p>
  11 + <p>对话框内容</p>
  12 + <p>对话框内容</p>
  13 + </Modal>
6 14 </div>
7 15 </template>
8 16 <script>
9 17 export default {
  18 + data () {
  19 + return {
  20 + modal1: false
  21 + }
  22 + },
10 23 methods: {
11   - confirm () {
12   - this.$Modal.confirm({
13   - title: '确认对话框标题',
14   - content: '<p>一些对话框内容</p><p>一些对话框内容</p>',
15   - onOk: () => {
16   - this.$Message.info('点击了确定');
17   - },
18   - onCancel: () => {
19   - this.$Message.info('点击了取消');
20   - }
21   - });
22   - },
23   - custom () {
24   - this.$Modal.confirm({
25   - title: '确认对话框标题',
26   - content: '<p>一些对话框内容</p><p>一些对话框内容</p>',
27   - okText: 'OK',
28   - cancelText: 'Cancel'
29   - });
  24 + ok () {
  25 + this.$Message.info('点击了确定');
30 26 },
31   - async () {
32   - this.$Modal.confirm({
33   - title: '确认对话框标题',
34   - content: '<p>对话框将在 2秒 后关闭</p>',
35   - loading: true,
36   - onOk: () => {
37   - setTimeout(() => {
38   - this.$Modal.remove();
39   - this.$Message.info('异步关闭了对话框');
40   - }, 2000);
41   - }
42   - });
  27 + cancel () {
  28 + this.$Message.info('点击了取消');
43 29 }
44 30 }
45 31 }
... ...
src/components/modal/modal.vue
1 1 <template>
2 2 <span>
3   - <transition name="fade">
  3 + <transition :name="transitionNames[1]">
4 4 <div :class="maskClasses" v-show="visible" @click="mask"></div>
5 5 </transition>
6 6 <div :class="wrapClasses" @click="handleWrapClick">
7   - <transition name="ease">
  7 + <transition :name="transitionNames[0]">
8 8 <div :class="classes" :style="mainStyles" v-show="visible">
9 9 <div :class="[prefixCls + '-content']">
10 10 <a :class="[prefixCls + '-close']" v-if="closable" @click="close">
... ... @@ -82,6 +82,12 @@
82 82 scrollable: {
83 83 type: Boolean,
84 84 default: false
  85 + },
  86 + transitionNames: {
  87 + type: Array,
  88 + default () {
  89 + return ['ease', 'fade'];
  90 + }
85 91 }
86 92 },
87 93 data () {
... ...