vue 拦截请求,添加请求头

来源:互联网 发布:苹果电脑装mac os 编辑:程序博客网 时间:2024/06/05 11:08

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


0 0
原创粉丝点击