赞
踩
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();
......
})
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。