Import vue from ' Vue 'Import Router from‘.. /router 'Import Axios from' Axios 'Import {Indicator} from' Mint-ui '; import {Toast} from' Mint-ui '; Axios.defaults.timeout= 30000; axios.defaults.headers.common[' Content-type '] = ' application/json;charset=utf-8 '//http request Blockeraxios.interceptors.request.use (config={Indicator.open ({text:' Load in ... ', Spinnertype:' Fading-circle ' }); returnconfig; }, Err={indicator.close (); Toast ({message:' Load timeout ', Position:' Middle ', Duration:3000 }); returnPromise.reject (ERR); });//HTTP Response InterceptorAxios.interceptors.response.use (Response={Let Timetp=NULL; Cleartimeout (TIMETP); TIMETP= SetTimeout (() ={indicator.close (); Cleartimeout (TIMETP); },500) //indicator.close (); returnresponse; }, Error= { if(error.response) {returnpromise.reject (Error)}}); Vue.prototype. $ajax= Axios;
Using the Axios request Interceptor, the response interceptor implements the loading layer effect