一般情况下我们设置header都是在axios的响应拦截器中进行设置,如下面代码所示:
axios.interceptors.request.use(function(config){
//比如是否需要设置 token
config.headers.token='eysasmdsakwnfnasdklasj'
return config
})
不过我们可以试想一下axios有没有提供给我们一个一劳永逸的方法,设置或删除某个特定的header呢,让它在每次请求中都出现。
axios文档中恰好有相关设置,上图中的代码意味着每次请求设置都会被响应。
store中的代码
mutations:{
login(state,rawData){
const