-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Close #419
- Loading branch information
Showing
5 changed files
with
72 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { | ||
NavigationGuardWithThis, | ||
NavigationGuard, | ||
RouteLocationNormalizedLoaded, | ||
} from './types' | ||
import { Router } from './router' | ||
|
||
declare module 'vue' { | ||
export interface ComponentCustomOptions { | ||
/** | ||
* Guard called when the router is navigating to the route that is rendering | ||
* this component from a different route. Differently from `beforeRouteUpdate` | ||
* and `beforeRouteLeave`, `beforeRouteEnter` does not have access to the | ||
* component instance through `this` because it triggers before the component | ||
* is even mounted. | ||
* | ||
* @param to - RouteLocationRaw we are navigating to | ||
* @param from - RouteLocationRaw we are navigating from | ||
* @param next - function to validate, cancel or modify (by redirecting) the | ||
* navigation | ||
*/ | ||
beforeRouteEnter?: NavigationGuardWithThis<undefined> | ||
|
||
/** | ||
* Guard called whenever the route that renders this component has changed but | ||
* it is reused for the new route. This allows you to guard for changes in | ||
* params, the query or the hash. | ||
* | ||
* @param to - RouteLocationRaw we are navigating to | ||
* @param from - RouteLocationRaw we are navigating from | ||
* @param next - function to validate, cancel or modify (by redirecting) the | ||
* navigation | ||
*/ | ||
beforeRouteUpdate?: NavigationGuard | ||
|
||
/** | ||
* Guard called when the router is navigating away from the current route that | ||
* is rendering this component. | ||
* | ||
* @param to - RouteLocationRaw we are navigating to | ||
* @param from - RouteLocationRaw we are navigating from | ||
* @param next - function to validate, cancel or modify (by redirecting) the | ||
* navigation | ||
*/ | ||
beforeRouteLeave?: NavigationGuard | ||
} | ||
|
||
export interface ComponentCustomProperties { | ||
/** | ||
* Normalized current location. See {@link RouteLocationNormalizedLoaded}. | ||
*/ | ||
$route: RouteLocationNormalizedLoaded | ||
/** | ||
* {@link Router} instance used by the application. | ||
*/ | ||
$router: Router | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Router, RouteLocationNormalizedLoaded, expectType } from './index' | ||
import { defineComponent } from 'vue' | ||
|
||
defineComponent({ | ||
methods: { | ||
doStuff() { | ||
expectType<Router>(this.$router) | ||
expectType<RouteLocationNormalizedLoaded>(this.$route) | ||
}, | ||
}, | ||
}) |