通过vue-resource发出请求,我想在所有的请求发出的时候都调用等待框,看了文档不太明白怎么在全局下设置vue-resource,请指教?
前几天刚好做了个这样的功能
注册之后:
Vue.http.interceptors.push(function (request, next) {
// 调用等待框,此处的 this 为发起请求的 component
next(function (response) {
// 消掉等待框,此处的 this 为发起请求的 component
})
})
https://github.com/vuejs/vue-resource/blob/master/docs/http.md#interceptors
官方文档