//axios请求拦截
//设置拦截器
axios.interceptors.request.use(config =>{
console.log(config)
//为请求头对象,添加token验证的Authoorization字段
config.headers."这里是token的key值" = window.localStorage.getItem('token的value值')
return config
}
)
前端发送请求时自动带上token
最新推荐文章于 2024-10-19 16:40:19 发布