|
1 | 1 | # Router Construction Options |
| 2 | + |
| 3 | +### routes |
| 4 | + |
| 5 | +- type: `Array<RouteConfig>` |
| 6 | + |
| 7 | + Type declaration for `RouteConfig`: |
| 8 | + |
| 9 | + ``` js |
| 10 | + declare type RouteConfig = { |
| 11 | + path: string; |
| 12 | + component?: Component; |
| 13 | + name?: string; // for named routes |
| 14 | + components?: { [name: string]: Component }; // for named views |
| 15 | + redirect?: string | Location | Function; |
| 16 | + alias?: string | Array<string>; |
| 17 | + children?: Array<RouteConfig>; // for nested routes |
| 18 | + beforeEnter?: (route: Route, redirect: Function, next: Function) => void; |
| 19 | + meta?: any; |
| 20 | + } |
| 21 | + ``` |
| 22 | + |
| 23 | +### mode |
| 24 | + |
| 25 | +- type: `string` |
| 26 | + |
| 27 | +- default: `"hash" (in browser) | "abstract" (in Node.js)` |
| 28 | + |
| 29 | +- available values: `"hash" | "history" | "abstract"` |
| 30 | + |
| 31 | + Configure the router mode. |
| 32 | + |
| 33 | + - `hash`: uses the URL hash for routing. Works in all Vue-supported browsers, including those that do not support HTML5 History API. |
| 34 | + |
| 35 | + - `history`: requires HTML5 History API and server config. See [HTML5 History Mode](../essentials/history.md). |
| 36 | + |
| 37 | + - `abstract`: works in all JavaScript environments, e.g. server-side with Node.js. **The router will automatically be forced into this mode if no browser API is present.** |
| 38 | + |
| 39 | +### base |
| 40 | + |
| 41 | +- type: `string` |
| 42 | + |
| 43 | +- default: `"/"` |
| 44 | + |
| 45 | + The base URL of the app. For example, if the entire single page application is served under `/app/`, then `base` should use the value `"/app/"`. |
| 46 | + |
| 47 | +### linkActiveClass |
| 48 | + |
| 49 | +- type: `string` |
| 50 | + |
| 51 | +- default: `"router-link-active"` |
| 52 | + |
| 53 | + Globally configure `<router-link>` default active class. Also see [router-link](router-link.md). |
| 54 | + |
| 55 | +### scrollBehavior |
| 56 | + |
| 57 | +- type: `Function` |
| 58 | + |
| 59 | + Signature: |
| 60 | + |
| 61 | + ``` |
| 62 | + ( |
| 63 | + to: Route, |
| 64 | + from: Route, |
| 65 | + savedPosition?: { x: number, y: number } |
| 66 | + ) => { x: number, y: number } | { selector: string } | ?{} |
| 67 | + ``` |
| 68 | + |
| 69 | + For more details see [Scroll Behavior](../advanced/scroll-behavior.md). |
0 commit comments