Loading... 在一个可登陆的项目中一般会用axios设置全局的请求头,但是我如果在一个请求路径中想不要加上默认的全局请求头比如token等要怎么做 这里说一个简单的思路,直接在设置请求拦截的时候进行config.url判断 ``` // 设置请求拦截器 console.log(vm) axios.interceptors.request.use(config => { const token = localStorage.getItem('token') if (token && config.url !== '/login') { config.headers.Authorization = 'Bearer ' + token } return config }) ``` Last modification:November 26th, 2019 at 04:57 pm © 允许规范转载 Support If you think my article is useful to you, please feel free to appreciate ×Close Appreciate the author Sweeping payments Pay by AliPay Pay by WeChat