Releases: vuejs/vue-router
v2.0.1
Fixed
- #707 using
tagprop on<router-link>breaks navigation (@fnlctrl via #708) - #725 beforeEnter fire twice on root path ('/') after async
nextcall (@billouboq via #735) - #726
router.gonot working in abstract mode - #750
nextinbeforeRouteEntersometimes doesn't receive vm instance - #756 avoid navigation on non-left-clicks (@LinusBorg via #758)
v2.0.0-rc.7
Fixed
- Fix abstract history missing
this.ensureURLduring SSR - Update TypeScript declarations to match 2.0.0-rc.6 changes
v2.0.0-rc.6
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.
v2.0.0-rc.5
New
- Route config
redirectoption now supports using a function, which receives the target route as the argument and should return redirect destination. See example. (@fnlctrl) - The
redirectoption's value can now be any valid location descriptor. By default, thequeryandhashof the original route will be passed along to the redirected route - however they can now be explicitly overwritten by theredirectoption when using the object location descriptor (or by returning it from a function).
Fixed
v2.0.0-rc.4
New
-
Now route components can also define the
beforeRouteEnterhook, in addition tobeforeRouteLeave. The difference here is that the before hook does not have access tothisbecause 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
nextfunction for thebeforeRouteEnterhook 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
New
- Expose
metaon$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 owntoprop instead of resolved route (e.g. a redirect destination).
v2.0.0-rc.2
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 callrouter.push(initialLocation)to set its initial location.
Fixed
$route.nameis now always exposed for named routes.
v2.0.0-rc.1
[release] 2.0.0-rc.1
v2.0.0-beta.4
Fixed
- #587 2.0.0-beta.3 regression on initial path match
v2.0.0-beta.3
Fixed
- Fixed error when working with async components. (Also see new lazy loading example)