效果图
代码(src/main.js)
import Axios from 'axios'
import Qs from 'qs'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI)
Vue.prototype.qs=Qs;
Vue.prototype.$axios=Axios;
Vue.config.productionTip = false
let loadingInstance;
Axios.interceptors.request.use(function(config){
loadingInstance=ElementUI.Loading.service({fullscreen:true,text:"正在请求数据"});
return config;
}),function(error){
return Promise.reject(error);
}
Axios.interceptors.response.use(function(response){
loadingInstance.close();
return response;
}),function(error){
return Promise.reject(error);
}