import Vue from 'vue' import GlobalLoading from '@/components/GlobalLoading.vue' const LoadingConstructor = Vue.extend(GlobalLoading) let loadingInstance = null export default { show(text) { if (!loadingInstance) { loadingInstance = new LoadingConstructor({ el: document.createElement('div') }) document.body.appendChild(loadingInstance.$el) } loadingInstance.show(text) }, hide() { if (loadingInstance) { loadingInstance.hide() } }, setAnimation(animationData) { if (loadingInstance) { loadingInstance.setAnimationData(animationData) } } }