vue-router 路由拦截
在需要登录的路由里面加上这个配置,键名可以自己取以下代码就是判断有没有登录router.beforeEach((to, from, next) => {if (to.meta.isJurisdiction) {if (sessionStorage.getItem(‘username’)) {next();} else {next({path: ‘/login’})}} else {next();}})to.meta.isJurisdiction是判断进入的路由需不需要登
原创
2020-12-16 11:15:28 ·
488 阅读 ·
0 评论