Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

router.d.ts 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. import Vue, { ComponentOptions, PluginFunction, AsyncComponent } from "vue";
  2. type Component = ComponentOptions<Vue> | typeof Vue | AsyncComponent;
  3. type Dictionary<T> = { [key: string]: T };
  4. type ErrorHandler = (err: Error) => void;
  5. export type RouterMode = "hash" | "history" | "abstract";
  6. export type RawLocation = string | Location;
  7. export type RedirectOption = RawLocation | ((to: Route) => RawLocation);
  8. export type NavigationGuard<V extends Vue = Vue> = (
  9. to: Route,
  10. from: Route,
  11. next: (to?: RawLocation | false | ((vm: V) => any) | void) => void
  12. ) => any
  13. export declare class VueRouter {
  14. constructor (options?: RouterOptions);
  15. app: Vue;
  16. mode: RouterMode;
  17. currentRoute: Route;
  18. beforeEach (guard: NavigationGuard): Function;
  19. beforeResolve (guard: NavigationGuard): Function;
  20. afterEach (hook: (to: Route, from: Route) => any): Function;
  21. push (location: RawLocation, onComplete?: Function, onAbort?: ErrorHandler): void;
  22. replace (location: RawLocation, onComplete?: Function, onAbort?: ErrorHandler): void;
  23. go (n: number): void;
  24. back (): void;
  25. forward (): void;
  26. getMatchedComponents (to?: RawLocation | Route): Component[];
  27. onReady (cb: Function, errorCb?: ErrorHandler): void;
  28. onError (cb: ErrorHandler): void;
  29. addRoutes (routes: RouteConfig[]): void;
  30. resolve (to: RawLocation, current?: Route, append?: boolean): {
  31. location: Location;
  32. route: Route;
  33. href: string;
  34. // backwards compat
  35. normalizedTo: Location;
  36. resolved: Route;
  37. };
  38. static install: PluginFunction<never>;
  39. }
  40. type Position = { x: number, y: number };
  41. type PositionResult = Position | { selector: string, offset?: Position } | void;
  42. export interface RouterOptions {
  43. routes?: RouteConfig[];
  44. mode?: RouterMode;
  45. fallback?: boolean;
  46. base?: string;
  47. linkActiveClass?: string;
  48. linkExactActiveClass?: string;
  49. parseQuery?: (query: string) => Object;
  50. stringifyQuery?: (query: Object) => string;
  51. scrollBehavior?: (
  52. to: Route,
  53. from: Route,
  54. savedPosition: Position | void
  55. ) => PositionResult | Promise<PositionResult>;
  56. }
  57. type RoutePropsFunction = (route: Route) => Object;
  58. export interface PathToRegexpOptions {
  59. sensitive?: boolean;
  60. strict?: boolean;
  61. end?: boolean;
  62. }
  63. export interface RouteConfig {
  64. path: string;
  65. name?: string;
  66. component?: Component;
  67. components?: Dictionary<Component>;
  68. redirect?: RedirectOption;
  69. alias?: string | string[];
  70. children?: RouteConfig[];
  71. meta?: any;
  72. beforeEnter?: NavigationGuard;
  73. props?: boolean | Object | RoutePropsFunction;
  74. caseSensitive?: boolean;
  75. pathToRegexpOptions?: PathToRegexpOptions;
  76. }
  77. export interface RouteRecord {
  78. path: string;
  79. regex: RegExp;
  80. components: Dictionary<Component>;
  81. instances: Dictionary<Vue>;
  82. name?: string;
  83. parent?: RouteRecord;
  84. redirect?: RedirectOption;
  85. matchAs?: string;
  86. meta: any;
  87. beforeEnter?: (
  88. route: Route,
  89. redirect: (location: RawLocation) => void,
  90. next: () => void
  91. ) => any;
  92. props: boolean | Object | RoutePropsFunction | Dictionary<boolean | Object | RoutePropsFunction>;
  93. }
  94. export interface Location {
  95. name?: string;
  96. path?: string;
  97. hash?: string;
  98. query?: Dictionary<string | string[]>;
  99. params?: Dictionary<string>;
  100. append?: boolean;
  101. replace?: boolean;
  102. }
  103. export interface Route {
  104. path: string;
  105. name?: string;
  106. hash: string;
  107. query: Dictionary<string | string[]>;
  108. params: Dictionary<string>;
  109. fullPath: string;
  110. matched: RouteRecord[];
  111. redirectedFrom?: string;
  112. meta?: any;
  113. }