当前位置:   article > 正文

Element-ui 全局设置loading_element ui全局loading

element ui全局loading

main.js

 

import { Loading } from 'element-ui';

 


let loadingCount = 0;
let loading;

const startLoading = () => {
  loading = Loading.service({
    lock: true,
    text: '加载中……',
    background: 'rgba(0, 0, 0, 0.7)'
  });
};

const endLoading = () => {
  loading.close();
};

const showLoading = () => {
  if (loadingCount === 0) {
    startLoading();
  }
  loadingCount += 1;
};

const hideLoading = () => {
  if (loadingCount <= 0) {
    return;
  }
  loadingCount -= 1;
  if (loadingCount === 0) {
    endLoading();
  }
};

 

.....

 

Vue.prototype.request = function(json, callback, url, callbackData) {
     ....

      showLoading();
      axios({
        method: 'post',
        url: url,
        data: requeData,
        headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
      }).then(function(res) { 
        hideLoading();
        ......

      })
    }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/218934
推荐阅读
相关标签
  

闽ICP备14008679号