Skip to content

Releases: vuejs/vue-router

v2.0.1

13 Oct 07:04
Compare
Choose a tag to compare

Fixed

  • #707 using tag prop on <router-link> breaks navigation (@fnlctrl via #708)
  • #725 beforeEnter fire twice on root path ('/') after async next call (@billouboq via #735)
  • #726 router.go not working in abstract mode
  • #750 next in beforeRouteEnter sometimes doesn't receive vm instance
  • #756 avoid navigation on non-left-clicks (@LinusBorg via #758)

v2.0.0-rc.7

29 Sep 07:33
Compare
Choose a tag to compare
v2.0.0-rc.7 Pre-release
Pre-release

Fixed

  • Fix abstract history missing this.ensureURL during SSR
  • Update TypeScript declarations to match 2.0.0-rc.6 changes

v2.0.0-rc.6

28 Sep 21:20
Compare
Choose a tag to compare
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 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.

v2.0.0-rc.5

13 Sep 19:44
Compare
Choose a tag to compare
v2.0.0-rc.5 Pre-release
Pre-release

New

  • Route config redirect option now supports using a function, which receives the target route as the argument and should return redirect destination. See example. (@fnlctrl)
  • The redirect option's value can now be any valid location descriptor. By default, the query and hash of the original route will be passed along to the redirected route - however they can now be explicitly overwritten by the redirect option when using the object location descriptor (or by returning it from a function).

Fixed

  • #625 fix beforeRouteEnter for async components
  • #628 Allow trailing slashes in path comparison (@fnlctrl)
  • #629 add warning when named route has a default child route (@LinusBorg)
  • #635 fix active link matching for named routes + exact
  • vuejs/#3667 fix beforeRouteEnter next hook vm instance context

v2.0.0-rc.4

29 Aug 19:40
Compare
Choose a tag to compare
v2.0.0-rc.4 Pre-release
Pre-release

New

  • Now route components can also define the beforeRouteEnter hook, in addition to beforeRouteLeave. The difference here is that the before hook does not have access to this because it is called before the route is even confirmed (thus no component instance has been rendered yet).

    In some use cases, the user may want to use the hook to pre-fetch data before switching to the new route. However without a reference to the incoming instance there's no easy way to pass the data. To solve that, the next function for the beforeRouteEnter hook accepts a callback, which will be called with the vm instance once the route has been rendered:

    export default {
      data () {
        return { msg: null }
      },
    
      beforeRouteEnter (route, redirect, next) {
        fetchData(route.params.id, msg => {
          next(vm => {
            vm.msg = msg
          })
        })
      }
    }

    Note whether to use this pattern is ultimately a UX decision: it depends on whether you want to wait until data is resolved before switching to the new route, or do you want to switch instantly, and let the incoming component handle the fetching and loading state. Both are valid choices, so we are providing the API to achieve both.

  • Support returning Promises for async components

Fixed

  • #622 fix named routes active class matching

v2.0.0-rc.3

11 Aug 06:01
Compare
Choose a tag to compare
v2.0.0-rc.3 Pre-release
Pre-release

New

  • Expose meta on $route. Note that this only exposes the meta object of the deepest matched route record; to access parent route records' meta it is necessary to iterate through $route.matched. (@fnlctrl)

Fixed

  • <router-link> active class should be applied based on its own to prop instead of resolved route (e.g. a redirect destination).

v2.0.0-rc.2

05 Aug 21:33
Compare
Choose a tag to compare
v2.0.0-rc.2 Pre-release
Pre-release

New

  • New method: router.getMatchedComponents - returns the array of matched components (definition objects).

Breaking Changes

  • Removed method: router.setInitialLocation. Instead, when the router is in abstract mode (set explicitly or when run in Node.js), the router will start in a "no route" state. The user can then just call router.push(initialLocation) to set its initial location.

Fixed

  • $route.name is now always exposed for named routes.

v2.0.0-rc.1

05 Aug 21:30
Compare
Choose a tag to compare
v2.0.0-rc.1 Pre-release
Pre-release
[release] 2.0.0-rc.1

v2.0.0-beta.4

29 Jul 04:27
Compare
Choose a tag to compare
v2.0.0-beta.4 Pre-release
Pre-release

Fixed

  • #587 2.0.0-beta.3 regression on initial path match

v2.0.0-beta.3

28 Jul 20:22
Compare
Choose a tag to compare
v2.0.0-beta.3 Pre-release
Pre-release

Fixed