From 34b9abca0b290753bb295ac84d18d21f31bbbdf8 Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 1 May 2017 15:19:53 +0800 Subject: [PATCH] do not normalize to if already a route in getMatchedComponents() (fix #1381) --- src/index.js | 8 +++++--- types/router.d.ts | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index 3d09d1cd0..e50c0ea0a 100644 --- a/src/index.js +++ b/src/index.js @@ -158,9 +158,11 @@ export default class VueRouter { this.go(1) } - getMatchedComponents (to?: RawLocation): Array { - const route = to - ? this.resolve(to).route + getMatchedComponents (to?: RawLocation | Route): Array { + const route: any = to + ? to.matched + ? to + : this.resolve(to).route : this.currentRoute if (!route) { return [] diff --git a/types/router.d.ts b/types/router.d.ts index 04a364bb7..ac702ab11 100644 --- a/types/router.d.ts +++ b/types/router.d.ts @@ -28,7 +28,7 @@ declare class VueRouter { go (n: number): void; back (): void; forward (): void; - getMatchedComponents (to?: RawLocation): Component[]; + getMatchedComponents (to?: RawLocation | Route): Component[]; onReady (cb: Function, errorCb?: Function): void; onError (cb: Function): void; addRoutes (routes: RouteConfig[]): void;