let num = ''
// 定义一个请求拦截器
axios.interceptors.request.use(function (config) {
num++
store.state.isShow = true // 在请求发出之前进行一些操作
return config
}, function (error) {
console.log('请求错误')
// 对请求错误做些什么
console.log(error)
})
// 定义一个响应拦截器
axios.interceptors.response.use(function (data) {
num--
if(num <= 0){
store.state.isShow = false;// 在这里对返回的数据进行处理
} else {
store.state.isShow = true // 在请求发出之前进行一些操作
}
return data
})