1、可以将token存储在 localstorage里面,在一个统一的地方复写请求头,让每次请求都在header中带上这个token, 当token失效的时候,后端肯定会返回401,这个时候在你可以在前端代码中操作返回登陆页面,清除localstorage中的token就好。

2、Storage的localStorage长期有效,sessionStorage关闭浏览器时会自动清除

3、vue存放token:http://www.php.cn/js-tutorial-385356.html

4、vue存放token:   https://segmentfault.com/q/1010000007624160

 

 

 

 

 


---------------------
作者:漫玥刚花
来源:CSDN
原文:https://blog.csdn.net/gangsijay888/article/details/81984570

相关文章:

  • 2021-05-17
  • 2021-05-27
  • 2021-08-03
  • 2022-12-23
  • 2022-12-23
  • 2021-10-19
  • 2021-09-26
猜你喜欢
  • 2021-11-16
  • 2022-01-24
  • 2022-12-23
  • 2022-01-05
  • 2022-12-23
  • 2021-05-12
  • 2021-04-29
相关资源
相似解决方案