diff --git a/src/history/base.js b/src/history/base.js index 5b6f199c6..32d6dea89 100644 --- a/src/history/base.js +++ b/src/history/base.js @@ -64,9 +64,13 @@ export class History { transitionTo (location: RawLocation, onComplete?: Function, onAbort?: Function) { const route = this.router.match(location, this.current) this.confirmTransition(route, () => { + const prev = this.current this.updateRoute(route) onComplete && onComplete(route) this.ensureURL() + this.router.afterHooks.forEach(hook => { + hook && hook(route, prev) + }) // fire ready cbs once if (!this.ready) { @@ -183,12 +187,8 @@ export class History { } updateRoute (route: Route) { - const prev = this.current this.current = route this.cb && this.cb(route) - this.router.afterHooks.forEach(hook => { - hook && hook(route, prev) - }) } }