84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
使用next()和next(false)都没问题,使用next('/index')就报错
认证0级讲师
把堆栈打开看看。Maximum call stack size 是不是死循环了,堆栈超出限制。
Maximum call stack size
beforeEach
你这里不加条件判断,当next('/index');执行的时候beforeEach又会执行如此重复。我不太清楚你这么做的理由是什么,不过显然你不应该这样做。
next('/index');
if(con) { next('/index') } next()
我猜是next('/index')时也触发了beforeach
if (to.matched.some(record => record.meta.requiresAuth)) {
if(con) { next('/index') }
}else{
next()
}
官网上面的:
路由1:next('/index')路由index:next('/index')
死循环了
next('/index')又会调用beforeEach,我是这样写的 let isLogin = Boolean(store.state.token.token) if (!isLogin) { if (to.path !== '/login') { return next({ path: '/login' }) } else { next() } }else { if (to.path === '/login') { return next({path: '/posts'}) } next() }
把堆栈打开看看。
Maximum call stack size
是不是死循环了,堆栈超出限制。beforeEach
你这里不加条件判断,当
next('/index');
执行的时候beforeEach
又会执行如此重复。我不太清楚你这么做的理由是什么,不过显然你不应该这样做。我猜是next('/index')时也触发了beforeach
if (to.matched.some(record => record.meta.requiresAuth)) {
}else{
}
官网上面的:
路由1:next('/index')
路由index:next('/index')
死循环了