Skip to content

v2.0.0-rc.6

Pre-release
Pre-release
Compare
Choose a tag to compare
@yyx990803 yyx990803 released this 28 Sep 21:20
· 1199 commits to dev since this 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 next function 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 with false explicitly aborts the navigation.
    • next('/other-path') or next({ path: '/other-path' }): - calling with a string or location descriptor object aborts current navigation and starts a new one (same as redirect previously)

    Regardless of the arguments, the next function 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, redirect or abort and can make the guard functions very messy, so we decided to fold all three into the same function.