Blame view

src/components/spin/spin.js 1.38 KB
297648f1   梁灏   fixed #1063
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
  import Vue from 'vue';
  import Spin from './spin.vue';
  
  Spin.newInstance = properties => {
      const _props = properties || {};
  
      const Instance = new Vue({
          data: Object.assign({}, _props, {
  
          }),
          render (h) {
              let vnode = '';
              if (this.render) {
                  vnode = h(Spin, {
                      props: {
                          fix: true,
                          fullscreen: true
                      }
                  }, [this.render(h)]);
              } else {
                  vnode = h(Spin, {
                      props: {
                          size: 'large',
                          fix: true,
                          fullscreen: true
                      }
                  });
              }
              return h('div', {
                  'class': 'ivu-spin-fullscreen'
              }, [vnode]);
          }
      });
  
      const component = Instance.$mount();
      document.body.appendChild(component.$el);
      const spin = Instance.$children[0];
  
      return {
          show () {
              spin.visible = true;
          },
          remove (cb) {
              spin.visible = false;
              setTimeout(function() {
                  spin.$parent.$destroy();
                  document.body.removeChild(document.getElementsByClassName('ivu-spin-fullscreen')[0]);
                  cb();
              }, 500);
          },
          component: spin
      };
  };
  
  export default Spin;