loading-bar.js
1.06 KB
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
import LoadingBar from './loading-bar.vue';
import Vue from 'vue';
LoadingBar.newInstance = properties => {
const _props = properties || {};
const Instance = new Vue({
data: _props,
render (h) {
return h(LoadingBar, {
props: _props
});
}
});
const component = Instance.$mount();
document.body.appendChild(component.$el);
const loading_bar = Instance.$children[0];
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 () {
setTimeout(function() {
document.body.removeChild(document.getElementsByClassName('ivu-loading-bar')[0].parentElement);
}, 500);
}
};
};
export default LoadingBar;