Blame view

examples/routers/modal.vue 2.73 KB
6259471f   梁灏   support Modal
1
2
  <template>
      <div>
3ef24d5f   Aresn   $Modal support re...
3
          {{ val }}
77cf1cd5   Aresn   $Modal support SSR
4
5
6
          <Button @click="confirm">标准</Button>
          <Button @click="custom">自定义按钮文字</Button>
          <Button @click="async">异步关闭</Button>
dce5a3ea   Aresn   update Modal
7
8
9
10
11
12
13
14
15
16
          <Button type="primary" @click="modal1 = true">显示对话框</Button>
          <Modal
                  v-model="modal1"
                  title="普通的Modal对话框标题"
                  @on-ok="ok"
                  @on-cancel="cancel">
              <p>对话框内容</p>
              <p>对话框内容</p>
              <p>对话框内容</p>
          </Modal>
6259471f   梁灏   support Modal
17
18
19
20
      </div>
  </template>
  <script>
      export default {
dce5a3ea   Aresn   update Modal
21
22
          data () {
              return {
3ef24d5f   Aresn   $Modal support re...
23
24
                  modal1: false,
                  val: ''
dce5a3ea   Aresn   update Modal
25
26
              }
          },
6259471f   梁灏   support Modal
27
          methods: {
dce5a3ea   Aresn   update Modal
28
29
30
31
32
33
              ok () {
                  this.$Message.info('点击了确定');
              },
              cancel () {
                  this.$Message.info('点击了取消');
              },
77cf1cd5   Aresn   $Modal support SSR
34
35
36
37
              confirm () {
                  this.$Modal.confirm({
                      title: '确认对话框标题',
                      content: '<p>一些对话框内容</p><p>一些对话框内容</p>',
3ef24d5f   Aresn   $Modal support re...
38
39
40
41
42
43
44
45
46
47
48
49
50
                      render: (h) => {
                          return h('Input', {
                              props: {
                                  value: this.val,
                                  autofocus: true
                              },
                              on: {
                                  input: (val) => {
                                      this.val = val;
                                  }
                              }
                          }, '一个按钮')
                      },
77cf1cd5   Aresn   $Modal support SSR
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
                      onOk: () => {
                          this.$Message.info('点击了确定');
                      },
                      onCancel: () => {
                          this.$Message.info('点击了取消');
                      }
                  });
              },
              custom () {
                  this.$Modal.confirm({
                      title: '确认对话框标题',
                      content: '<p>一些对话框内容</p><p>一些对话框内容</p>',
                      okText: 'OK',
                      cancelText: 'Cancel'
                  });
e5337c81   梁灏   fixed some compon...
66
              },
77cf1cd5   Aresn   $Modal support SSR
67
68
69
70
71
72
73
74
75
76
77
78
              async () {
                  this.$Modal.confirm({
                      title: '确认对话框标题',
                      content: '<p>对话框将在 2秒 后关闭</p>',
                      loading: true,
                      onOk: () => {
                          setTimeout(() => {
                              this.$Modal.remove();
                              this.$Message.info('异步关闭了对话框');
                          }, 2000);
                      }
                  });
6259471f   梁灏   support Modal
79
80
81
82
              }
          }
      }
  </script>