Skip to content

Commit 4cb563a

Browse files
committed
more docs
1 parent 30868f3 commit 4cb563a

File tree

5 files changed

+99
-3
lines changed

5 files changed

+99
-3
lines changed

docs/SUMMARY.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
- [Installation](installation.md)
44
- [Basic Usage](basic.md)
55
- [Nested Routes](nested.md)
6-
- [Route Object](route.md)
6+
- [Route Object & Route Matching](route.md)
7+
- [Router Options](options.md)
78
- [router-view](view.md)
89
- [v-link](link.md)
9-
- [Router Options](options.md)
1010
- Transition Pipeline
1111
- [Overview](pipeline/README.md)
1212
- [Transition Object](pipeline/transition.md)

docs/link.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,25 @@
11
# v-link
2+
3+
You should use the `v-link` directive for handling navigations inside a vue-router-enabled app for the following reasons:
4+
5+
- It works the same way in both HTML5 history mode and hash mode, so if you ever decide to switch mode, or when the router falls back to hash mode in IE9, nothing needs to be changed.
6+
7+
- In HTML5 history mode, `v-link` will intercept the click event so that the browser doesn't try to reload the page.
8+
9+
- When you are using the `root` option in HTML5 history mode, you don't need to include it in `v-link` URLs.
10+
11+
#### Active Link Class
12+
13+
Elements with `v-link` will automatically get corresponding class names when the current path matches its `v-link` URL:
14+
15+
- The `.v-link-active` class is applied to the element when the current path starts with the `v-link` URL. For example, an element with `v-link="/a"` will get this class as long as the current path starts with `/a`.
16+
17+
- The `.v-link-active-exact` class is applied when the current path is an exact match of the `v-link` URL.
18+
19+
The active link class name can be configured with the `activeLinkClass` option when creating the router instance. The exact match class simply appends `-exact` postfix to the provided class name.
20+
21+
#### Additional Notes
22+
23+
- `v-link` automatically sets the `href` attribute when used on an `<a>` element.
24+
25+
- Because `v-link` is a [literal directive](http://vuejs.org/guide/directives.html#Literal_Directives), it can contain mustache tags, e.g. `v-link="/user/{% raw %}{{user.name}}{% endraw %}"`.

docs/options.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,60 @@
11
# Route Options
2+
3+
There are a number of options you can use to customize the router behavior when creating a router instance.
4+
5+
#### hashbang
6+
7+
- default: true
8+
- only used in hash mode
9+
10+
When the hashbang option is true, all hash paths will be formated to start with `#!`. For example `router.go('/foo/bar')` will set the browser URL to `example.com/#!/foo/bar`.
11+
12+
#### history
13+
14+
- default: false
15+
16+
Enables HTML5 history mode. Leverages `history.pushState()` and `history.replaceState()` for history management.
17+
18+
**Note**: when using the history mode, the server needs to be [properly configured](http://readystate4.com/2012/05/17/nginx-and-apache-rewrite-to-support-html5-pushstate/) so that a user directly visiting a deep link on your site doesn't get a 404.
19+
20+
#### abstract
21+
22+
- default: false
23+
24+
Use an abstract history backend that doesn't rely on the browser. The abstract mode is useful in testing or in environments where actual URLs doesn't matter, for example in Electron or Cordova apps. The router will also fallback into abstract mode if loaded in a non-browser environment.
25+
26+
#### root
27+
28+
- default: null
29+
- only used in HTML5 history mode
30+
31+
Define a root path for all router navigations. All paths used in route configurations, `router.go()`, `v-link` and exposed on route objects will be resolved relative to this root path, and the root path will always be included in the actual browser URL.
32+
33+
For example, with `root: '/foo'`, `v-link="/bar"` will set the browser URL to `/foo/bar`. Directly visiting `/foo/bar` will match against `/bar` in your route config.
34+
35+
In most cases, `root` is set-and-forget: you don't have to worry about it in your application code.
36+
37+
#### linkActiveClass
38+
39+
- default: `"v-link-active"`
40+
41+
Configures the class to be applied to `v-link` elements when the current path matches its URL. The base class is applied as long as the current path starts with the `v-link` URL; when the current path matches the `v-link` URL exactly, an additional class with the `-exact` postfix will also be applied,the default being `v-link-active-exact`. So if you configure the class to be `my-custom-active`, the exact match class will be `my-custom-active-exact`.
42+
43+
#### saveScrollPosition
44+
45+
- default: false
46+
- only used in HTML5 history mode
47+
48+
This option leverages the state associated with an HTML5 history `popstate` event to restore the scroll position when the user hits the back button. Note this might not work as expected if your `<router-view>` has transition effects.
49+
50+
#### transitionOnLoad
51+
52+
- default: false
53+
54+
Whether to apply transition effect for `<router-view>`s on initial load. By default the components matched on initial load are rendered instantly.
55+
56+
#### suppressTransitionError
57+
58+
- default: false
59+
60+
If set to `true`, uncaught errors inside transition hooks will be suppressed.

docs/route.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Route Object
1+
# Route Object & Route Matching
22

33
Vue-router supports matching paths that contain dynamic segments, star segments and query strings. All these information of a parsed route will be accessible on the exposed **Route Context Objects** (we will just call them "route" objects from now on). The route object will be injected into every component in a vue-router-enabled app as `this.$route`, and will be updated whenever a route transition is performed.
44

docs/view.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# `<router-view>`
2+
3+
The `<router-view>` element is used as outlets for rendering matched components. It is based upon Vue's dynamic component system, and therefore inherits many features from a normal dyanmic component:
4+
5+
- You can pass props to it.
6+
- HTML content inside the `<router-view>` will be used for content insertion in the rendered component.
7+
- `v-transition` and `transition-mode` are fully supported. Note: for transition effects to work, your route component must not be a [fragment instance](http://vuejs.org/guide/best-practices.html#Fragment_Instance).
8+
- `v-ref` is also supported; The rendered component will be registered in the parent component's `this.$` object.
9+
10+
However, there are also a few limitations:
11+
12+
- `keep-alive` is not supported as of now.
13+
- `wait-for` is not supported. You should be using the [`activate` transition hook](pipeline/activate.html) to control the timing of the transition.

0 commit comments

Comments
 (0)