iview/src/components/loading-bar/loading-bar.js

42 lines
1.1 KiB
JavaScript
Raw Normal View History

import LoadingBar from './loading-bar.vue';
import Vue from 'vue';
LoadingBar.newInstance = properties => {
const _props = properties || {};
2017-06-01 11:07:30 +08:00
const Instance = new Vue({
data: _props,
render (h) {
return h(LoadingBar, {
props: _props
});
}
});
2017-06-01 11:07:30 +08:00
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 () {
2017-06-01 11:07:30 +08:00
setTimeout(function() {
document.body.removeChild(document.getElementsByClassName('ivu-loading-bar')[0].parentElement);
}, 500);
}
2016-12-25 22:49:42 +08:00
};
};
export default LoadingBar;