vue路由前卫拦截

tech2025-09-01  5

vue路由前卫拦截

报错:RangeError: Maximum call stack size exceeded at VueRouter.match 循环多次

修改(排除页面)

/* 挂载路由导航守卫 to:要访问的路径 from:从哪里来的路径 next:是一个函数,放行 */ router.beforeEach((to, from, next) => { let token = localStorage.getItem('token'); const outerPaths = ['/login']; if (!token && !outerPaths.includes(to.path)) { next({ path: '/login', replace: true }); } else { next(); } });
最新回复(0)