index.js 672 B

1234567891011121314151617181920212223242526272829303132333435
  1. import vue from 'vue'
  2. import loadingComponent from './loading.vue'
  3. const LoadingConstructor = vue.extend(loadingComponent)
  4. let LoadingDom
  5. function showLoading () {
  6. if (!LoadingDom) {
  7. LoadingDom = new LoadingConstructor({
  8. el: document.createElement('div'),
  9. data () {
  10. return {
  11. show: true
  12. }
  13. }
  14. })
  15. document.body.appendChild(LoadingDom.$el)
  16. } else {
  17. LoadingDom.show = true
  18. }
  19. }
  20. function hideLoading () {
  21. if (LoadingDom) {
  22. LoadingDom.show = false
  23. }
  24. }
  25. function registryLoading () {
  26. vue.prototype.$showLoading = showLoading
  27. vue.prototype.$hideLoading = hideLoading
  28. }
  29. export default registryLoading