【Vue】Vue Router导航守卫 Maximum call stack size exceeded next path 解决方案

        全局前置导航守卫中需要调用next()方法来resolve这个钩子,可以通过往next()里传入如:replace:true 、name:'home' 执行结果依赖next方法的调用参数。

        当配置 next() 时会出现死循环或路由栈溢出,原因是当执行钩子函数时,如果遇到 next('/home'),会触发离开的钩子,然后再次触发前置导航钩子,此时 to.path 已经是 home。因此只需加一层判断,判断如果to.path 是/home,直接next().

【Vue】Vue Router导航守卫 Maximum call stack size exceeded next path 解决方案