使用vue beforeRouteLeave出现下面错误,是因为出现了死循环, 因为在调用next('/mine')时, 又重新触发了beforeRouteLeave, 从而又执行了next('/mine'), 所以出现了死循环。
RangeError: Maximum call stack size exceeded

处理方式,判断下当前路由地址。
beforeRouteLeave(to, from, next) {
if (to.fullPath === '/mine') {
return next()
} else if (to.path == '/mine/refund') {
next({ path: '/mine' });
} else {
next()
}
}
网友评论