vue中安装axios文档:http://www.axios-js.com/docs/vue-axios.html

axios.defaults.baseURL = 'http://47.115.124.102:8888/api/private/v1/';
/*为每个请求添加一个拦截器,作用是在每个请求头中添加自定义变量为authorization的token信息*/
axios.interceptors.request.use(config=>{
  /*发送请求时,进度条开始*/
  NProgress.start()
  config.headers.authorization=window.sessionStorage.getItem('token')
  return config
})
axios.interceptors.response.use(config=>{
  /*请求完成后,进度条结束*/
  NProgress.done()
  return config
})

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-28
  • 2022-12-23
  • 2021-12-30
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-11
  • 2022-12-23
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案