You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/en/essentials/getting-started.md
+12-10
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# Basic Usage
1
+
# Getting Started
2
2
3
3
Creating a Single-page Application with Vue.js + vue-router is dead simple. With Vue.js, we are already dividing our application into components. When adding vue-router to the mix, all we need to do is map our components to the routes and let vue-router know where to render them. Here's a basic example:
4
4
@@ -11,10 +11,11 @@ Creating a Single-page Application with Vue.js + vue-router is dead simple. With
11
11
<!-- use router-link component for navigation. -->
12
12
<!-- specify the link by passing the `to` prop. -->
13
13
<!-- <router-link> will be rendered as an `<a>` tag by default -->
14
-
<router-link:to="{ path: '/foo' }">Go to Foo</router-link>
14
+
<router-linkto="/foo">Go to Foo</router-link>
15
15
<router-linkto="/bar">Go to Bar</router-link>
16
16
</p>
17
17
<!-- route outlet -->
18
+
<!-- component matched by the route will render here -->
18
19
<router-view></router-view>
19
20
</div>
20
21
```
@@ -27,7 +28,8 @@ Creating a Single-page Application with Vue.js + vue-router is dead simple. With
27
28
// and injects $router and $route to all router-enabled child components
28
29
Vue.use(VueRouter)
29
30
30
-
// 2. Define route components
31
+
// 2. Define route components.
32
+
// These can be imported from other files
31
33
var Foo = { template:'<div>foo</div>' }
32
34
var Bar = { template:'<div>bar</div>' }
33
35
@@ -49,21 +51,21 @@ var router = new VueRouter({
49
51
})
50
52
51
53
// 5. Create and mount the root instance.
52
-
// Make sure to inject the router.
53
-
// Route components will be rendered inside <router-view>.
54
-
// The root instance will mount to
55
-
// the element matching the selector #app.
54
+
// Make sure to inject the router with the router option to make the
55
+
// whole app router-aware.
56
56
newVue({
57
57
router: router
58
58
}).$mount('#app')
59
59
60
60
// Now the app has started!
61
61
```
62
62
63
-
You can also checkout this example [live](http://jsfiddle.net/fnlCtrl/t49c0mqz/).
63
+
You can also checkout this example [live](http://jsfiddle.net/yyx990803/xgrjzsup/).
64
64
65
65
In addition:
66
66
67
-
-The root Vue instance will be available as `router.app` once the initial render is complete.
67
+
-Notice that a `<router-link>` automatically gets the `.router-link-active` class when its target route is matched. You can learn more about it in its [API reference](../api/router-link.md).
68
68
69
-
- The router instance will be available in all descendants of the root instance as `this.$router`.
69
+
- The root Vue instance will be available as `router.app` once the initial render is complete. You can learn more about the properties and methods available on the router instance [here](../api/router-instance.md).
70
+
71
+
- The router instance will be available in all descendants of the root instance as `this.$router`. An object representing the current route state will also be available as [this.$route](../api/route-object.md).
0 commit comments