在Vue中如何使用Cookie操作实例(3)

//这个是请求页面路由的时候会验证token存不存在,不存在的话会到登录页 router.beforeEach((to, from, next) => { if(to.meta.requireAuth) { fetch('m/is/login').then(res => { if(res.errCode == 200) { next(); } else { if(getCookie('session')) { delCookie('session'); } if(getCookie('u_uuid')) { delCookie('u_uuid'); } next({ path: 'https://www.jb51.net/' }); } }); } else { next(); } }); export default router;


以上就是Cookie在项目中的使用,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wyjzgp.html