Skip to content

Commit f725c0f

Browse files
committed
complete docs
1 parent d7e778e commit f725c0f

File tree

9 files changed

+135
-7
lines changed

9 files changed

+135
-7
lines changed

docs/en/SUMMARY.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
- [Redirect and Alias](essentials/redirect-and-alias.md)
1515
- [HTML5 History Mode](essentials/history-mode.md)
1616
- Advanced
17-
- [Navigation Hooks](advanced/navigation-guards.md)
17+
- [Navigation Guards](advanced/navigation-guards.md)
1818
- [Route Meta Fields](advanced/meta.md)
1919
- [Transitions](advanced/transitions.md)
2020
- [Data Fetching](advanced/data-fetching.md)
@@ -25,6 +25,5 @@
2525
- [router-view](api/router-view.md)
2626
- [The Route Object](api/route-object.md)
2727
- [Router Constructor Options](api/options.md)
28-
- [Routes Configuration](api/route-config.md)
2928
- [Router Instance](api/router-instance.md)
3029
- [Component Injections](api/component-injections.md)

docs/en/advanced/navigation-guards.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Global before guards are called in creation order, whenever a navigation is trig
1818

1919
Every guard function receives three arguments:
2020

21-
- `route: Route`: the target route object being navigated to.
21+
- `route: Route`: the target [Route Object](../api/route-object.md) being navigated to.
2222

2323
- `redirect: Function`: calling this function will abort the current navigation and start a new navigation towards the redirect target.
2424

docs/en/api/component-injections.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Component Injections
2+
3+
### Injected Properties
4+
5+
These properties are injected into every child component by passing the router instance to the root instance as the `router` option.
6+
7+
- #### $router
8+
9+
The router instance.
10+
11+
- #### $route
12+
13+
The current active [Route](route-object.md). This property is read-only and its properties are immutable, but it can be watched.
14+
15+
### Enabled Options
16+
17+
- **beforeRouteEnter**
18+
- **beforeRouteLeave**
19+
20+
See [In Component Guards](../advanced/navigation-guards.md#incomponent-guards).

docs/en/api/options.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,69 @@
11
# 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).

docs/en/api/route-config.md

Whitespace-only changes.

docs/en/api/router-instance.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Router Instance
2+
3+
### Properties
4+
5+
#### router.app
6+
7+
- type: `Vue instance`
8+
9+
The root Vue instance the `router` was injected into.
10+
11+
#### router.mode
12+
13+
- type: `string`
14+
15+
The [mode](options.md#mode) the router is using.
16+
17+
#### router.currentRoute
18+
19+
- type: `Route`
20+
21+
The current route represented as a [Route Object](route-object.md).
22+
23+
### Methods
24+
25+
- **router.beforeEach(guard)**
26+
- **router.afterEach(hook)**
27+
28+
Add global navigation guards. See [Navigation Guards](../advanced/navigation-gaurds.md).
29+
30+
31+
- **router.push(location)**
32+
- **router.replace(location)**
33+
- **router.go(n)**
34+
- **router.back()**
35+
- **router.forward()**
36+
37+
Programmatically navigate to a new URL. See [Programmatic Navigation](../essentials/navigation.md).
38+
39+
- **router.getMatchedComponents()**
40+
41+
Returns an Array of the components (definition/constructor, not instances) matched by the current route. This is mostly used during server-side rendering to perform data prefetching.

docs/en/api/router-link.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
- **to**
1616

17-
- type: `string | Object`
17+
- type: `string | Location`
1818

1919
- required
2020

@@ -86,7 +86,7 @@
8686

8787
- default: `"router-link-active"`
8888

89-
Configure the active CSS class applied when the link is active.
89+
Configure the active CSS class applied when the link is active. Note the default value can also be configured globally via the `linkActiveClass` router constructor option.
9090

9191
- **exact**
9292

docs/en/essentials/history-mode.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ https://github.com/bripkens/connect-history-api-fallback
4646

4747
There is a caveats to this, because that your server will no longer report 404 errors as all paths will serve up your `index.html` file. To get around the issue, you should implement a catch-all route within your Vue app to show a 404 page:
4848

49-
```javascript
49+
``` js
5050
const router = new VueRouter({
5151
mode: 'history',
5252
routes: [

flow/declarations.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ declare type RouterOptions = {
1313
scrollBehavior?: Function;
1414
}
1515

16-
declare type RedirectOption = string | { name: string } | Function
16+
declare type RedirectOption = RawLocation | Function
1717

1818
declare type RouteConfig = {
1919
path: string;

0 commit comments

Comments
 (0)