-
-
Notifications
You must be signed in to change notification settings - Fork 5k
/
Copy pathrouter.d.ts
94 lines (83 loc) · 2.24 KB
/
router.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import Vue = require("vue");
import { ComponentOptions, PluginFunction } from "vue";
type Component = ComponentOptions<Vue> | typeof Vue;
type Dictionary<T> = { [key: string]: T };
export type RouterMode = "hash" | "history" | "abstract";
export type RawLocation = string | Location;
export type RedirectOption = RawLocation | ((to: Route) => RawLocation);
export type NavigationGuard = (
to: Route,
from: Route,
next: (to?: RawLocation | false | ((vm: Vue) => any) | void) => void
) => any
declare class VueRouter {
constructor (options?: RouterOptions);
app: Vue;
mode: RouterMode;
currentRoute: Route;
beforeEach (guard: NavigationGuard): void;
afterEach (hook: (to: Route, from: Route) => any): void;
push (location: RawLocation): void;
replace (location: RawLocation): void;
go (n: number): void;
back (): void;
forward (): void;
getMatchedComponentes (): Component;
resolve (to: RawLocation, current?: Route, append?: boolean): {href: string};
static install: PluginFunction<never>;
}
export interface RouterOptions {
routes?: RouteConfig[];
mode?: RouterMode;
base?: string;
linkActiveClass?: string;
scrollBehavior?: (
to: Route,
from: Route,
savedPosition: { x: number, y: number } | undefined
) => { x: number, y: number } | { selector: string } | void;
}
export interface RouteConfig {
path: string;
name?: string;
component?: Component;
components?: Dictionary<Component>;
redirect?: RedirectOption;
alias?: string | string[];
children?: RouteConfig[];
meta?: any;
beforeEnter?: NavigationGuard;
}
export interface RouteRecord {
path: string;
components: Dictionary<Component>;
instances: Dictionary<Vue>;
name?: string;
parent?: RouteRecord;
redirect?: RedirectOption;
matchAs?: string;
meta: any;
beforeEnter?: (
route: Route,
redirect: (location: RawLocation) => void,
next: () => void
) => any;
}
export interface Location {
name?: string;
path?: string;
hash?: string;
query?: Dictionary<string>;
params?: Dictionary<string>;
}
export interface Route {
path: string;
name?: string;
hash: string;
query: Dictionary<string>;
params: Dictionary<string>;
fullPath: string;
matched: RouteRecord[];
redirectedFrom?: string;
meta?: any;
}