w-component-ui
Version:
w Vue components project
31 lines (27 loc) • 883 B
JavaScript
import Loading from './WLoadding.vue';
let plugin = {};
let removeDom = event => {
event.target.parentNode.removeChild(event.target);
};
plugin.install = function(Vue){
const LoadingConstructor = Vue.extend(Loading);
LoadingConstructor.prototype.close = function () {
this.visible = false;
this.$el.addEventListener('transitionend', removeDom);
};
LoadingConstructor.prototype.opens = function () {
this.visible = true;
};
let instance;
Vue.prototype.$Loading = (option = {}) => {
instance = new LoadingConstructor().$mount(document.createElement('div'));
instance.opens();
instance.text = option.text || instance.text || option;
instance.loadingType = option.loadingType || instance.loadingType;
document.body.appendChild(instance.$el);
};
Vue.prototype.$closeLoad = () => {
instance.close();
}
};
export default plugin