Blame view

src/components/loading-bar/loading-bar.js 1.06 KB
9dde24b6   梁灏   add LoadingBar co...
1
2
  import LoadingBar from './loading-bar.vue';
  import Vue from 'vue';
9dde24b6   梁灏   add LoadingBar co...
3
4
5
6
  
  LoadingBar.newInstance = properties => {
      const _props = properties || {};
  
24c8f4ea   Aresn   LoadingBar suppor...
7
8
9
10
11
12
13
      const Instance = new Vue({
          data: _props,
          render (h) {
              return h(LoadingBar, {
                  props: _props
              });
          }
9dde24b6   梁灏   add LoadingBar co...
14
15
      });
  
24c8f4ea   Aresn   LoadingBar suppor...
16
17
18
      const component = Instance.$mount();
      document.body.appendChild(component.$el);
      const loading_bar = Instance.$children[0];
9dde24b6   梁灏   add LoadingBar co...
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
  
      return {
          update (options) {
              if ('percent' in options) {
                  loading_bar.percent = options.percent;
              }
              if (options.status) {
                  loading_bar.status = options.status;
              }
              if ('show' in options) {
                  loading_bar.show = options.show;
              }
          },
          component: loading_bar,
          destroy () {
24c8f4ea   Aresn   LoadingBar suppor...
34
35
36
              setTimeout(function() {
                  document.body.removeChild(document.getElementsByClassName('ivu-loading-bar')[0].parentElement);
              }, 500);
9dde24b6   梁灏   add LoadingBar co...
37
          }
b0893113   jingsam   :art: add eslint
38
      };
9dde24b6   梁灏   add LoadingBar co...
39
40
41
  };
  
  export default LoadingBar;