Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.2k views
in Technique[技术] by (71.8m points)

vue的token问题

请问一下,做的混合app,如果app登录了首页携带token我拿到保存到本地没问题,如果没登录进入页面,点击关注的时候跳到app登录页了app返给我了token,怎么把它放到封装好的http请求里面,因为之前的token是获取的本地存储,就执行了一次,现在获取到了加不到请求头,我用的vuex,能单独改header吗
image.png


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

无token时会跳到app登录页,登录成功跳转到h5,(token带在链接或者客户端提供获取方法);
你在 router.beforeEach 里面判断 并 获取token(从链接上获取或者其他方式),拿到commit,顺便再 存储就行了;
token添加就在http封装里面加,你的没问题;


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...