Vue.http.interceptors.push((request, next) => { // ... // 请求发送前的处理逻辑 if(token) { request.beforeSend = function() { request.headers['token'] = token.token; } } next((response) => { // ... // 请求发送后的处理逻辑 // ... // 根据请求的状态,response参数会返回给successCallback或errorCallback return response })
原文链接:
http://www.cnblogs.com/keepfool/p/5657065.html