Skip to content

v2.1.0

Compare
Choose a tag to compare
@yyx990803 yyx990803 released this 29 Nov 11:36
· 1095 commits to dev since this release

Dist File Change

The main for the NPM package is now vue-router.common.js. This requires no change for existing build setups. The only difference is that the CDN link for the browser-build is now https://unpkg.com/[email protected]/dist/vue-router.js.

New

  • New method: router.resolve() (@hogart via #918). The user can use this method to get a resolved route object or href string. The signature for this method is:

    resolve (to: RawLocation, current?: Route, append?: boolean): {
      normalizedTo: Location;
      resolved: Route;
      href: string;
    }
  • router.getMatchedComponents() can now resolve and determine the matched components for the location passed to it as argument. Note during server-side rendering, you will still need to explicitly router.push() the url so that the $route object is available to data preFetch functions.

  • router.push() and router.replace() can now accept a location object with just params:

    router.push({ params: { foo: 'bar' }})

    Note this will do nothing if the current active route doesn't have the matching params; it is your responsibility to ensure this only gets called on appropriate routes.

  • router.push() and router.replace() now also accept append: true in the location object:

    // will navigate to /foo/bar from /foo
    router.push({
      path: 'bar',
      append: true
    })
  • When using next in route navigation for a redirect, guards now accept replace: true in the location object:

    router.beforeEach((to, from, next) => {
      if (to.path === '/foo') {
        next({
          path: '/bar',
          replace: true
        })
      }
    })
  • New prop event for <router-link>, allows defining the events to trigger a navigation. Can be a string or an Array of strings.

Fixed

  • #853 fix hashchange listener not set up if initial route is a redirect
  • #906 fix named routes navigation using old route params (@znck via #917)
  • #908 respect deeper routes of the same path
  • #922 fix navigation without an app instance
  • #926 avoid rearranging query parameter orders (@miccycn via #946)