v2.0.0-rc.6
Pre-release
Pre-release
Breaking Change
-
Navigation guards signature change:
// before router.beforeEach((route, redirect, next) => { // ...call redirect or next, or call nothing }) // after router.beforeEach((to, from, next) => { // always call next })
The
nextfunction now serves as the only function that needs to be called (and must be called), but the behavior will be determined by the arguments:next()- calling with no arguments moves on to the next guard in the pipeline.next(false)- calling withfalseexplicitly aborts the navigation.next('/other-path')ornext({ path: '/other-path' }): - calling with a string or location descriptor object aborts current navigation and starts a new one (same asredirectpreviously)
Regardless of the arguments, the
nextfunction should always be called in all conditional branches.We are sorry for a breaking change in an RC release, but a way to explicitly abort the navigation is needed to fix #692. As a result the user needs to call one of
next,redirectorabortand can make the guard functions very messy, so we decided to fold all three into the same function.