]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
feat(router): add back,forward,go
authorEduardo San Martin Morote <posva13@gmail.com>
Tue, 21 Apr 2020 12:01:35 +0000 (14:01 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Tue, 21 Apr 2020 12:01:35 +0000 (14:01 +0200)
src/router.ts

index 269a4c62435cc0954e174d2c4e89553ccdfd6a4a..3bb368419b9e7924de45fe25f64803bc7c5582b6 100644 (file)
@@ -104,6 +104,11 @@ export interface Router {
 
   push(to: RouteLocationRaw): Promise<NavigationFailure | void>
   replace(to: RouteLocationRaw): Promise<NavigationFailure | void>
+  // TODO: return a promise when https://github.com/vuejs/rfcs/pull/150 is
+  // merged
+  back(): void
+  forward(): void
+  go(distance: number): void
 
   beforeEach(guard: NavigationGuardWithThis<undefined>): () => void
   afterEach(guard: PostNavigationGuard): () => void
@@ -605,10 +610,13 @@ export function createRouter({
     removeRoute,
     hasRoute,
     getRoutes,
+    resolve,
 
     push,
     replace,
-    resolve,
+    go: history.go,
+    back: () => history.go(-1),
+    forward: () => history.go(1),
 
     beforeEach: beforeGuards.add,
     afterEach: afterGuards.add,