Skip to content

Commit b49f54a

Browse files
committed
docs: update referral
1 parent 2a7f900 commit b49f54a

35 files changed

+263
-251
lines changed

docs/guide/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ We will be using [ES2015](https://github.com/lukehoban/es6features) in the code
66
Also, all examples will be using the full version of Vue to make on-the-fly template compilation possible. See more details [here](https://vuejs.org/v2/guide/installation.html#Runtime-Compiler-vs-Runtime-only).
77
:::
88

9-
<div class="vueschool"><a href="https://vueschool.io/courses/vue-router-for-everyone?friend=vuejs" target="_blank" rel="sponsored noopener" title="Learn how to build powerful Single Page Applications with the Vue Router on Vue School">Watch a free video course about Vue Router on Vue School</a></div>
9+
<div class="vueschool"><a href="https://vueschool.io/courses/vue-router-for-everyone?friend=vuerouter" target="_blank" rel="sponsored noopener" title="Learn how to build powerful Single Page Applications with the Vue Router on Vue School">Watch a free video course about Vue Router on Vue School</a></div>
1010

1111
Creating a Single-page Application with Vue + Vue Router feels natural: with Vue.js, we are already composing our application with 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:
1212

docs/guide/advanced/lazy-loading.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Lazy Loading Routes
22

3-
<div class="vueschool"><a href="https://vueschool.io/lessons/how-to-lazy-load-routes-with-vue-router?friend=vuejs" target="_blank" rel="sponsored noopener" title="Learn how to increase performance by lazy loading routes on Vue School">Learn how to lazy load routes with a free lesson on Vue School</a></div>
3+
<div class="vueschool"><a href="https://vueschool.io/lessons/how-to-lazy-load-routes-with-vue-router?friend=vuerouter" target="_blank" rel="sponsored noopener" title="Learn how to increase performance by lazy loading routes on Vue School">Learn how to lazy load routes with a free lesson on Vue School</a></div>
44

55
When building apps with a bundler, the JavaScript bundle can become quite large, and thus affect the page load time. It would be more efficient if we can split each route's components into a separate chunk, and only load them when the route is visited.
66

docs/guide/advanced/navigation-guards.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Remember that **params or query changes won't trigger enter/leave navigation gua
66

77
## Global Before Guards
88

9-
<div class="vueschool"><a href="https://vueschool.io/lessons/how-to-configure-an-authentication-middleware-route-guard-with-vue-router?friend=vuejs" target="_blank" rel="sponsored noopener" title="Learn how to create an authentication middleware with a global route guard on Vue School">Learn how navigation guards works with a free lesson on Vue School</a></div>
9+
<div class="vueschool"><a href="https://vueschool.io/lessons/how-to-configure-an-authentication-middleware-route-guard-with-vue-router?friend=vuerouter" target="_blank" rel="sponsored noopener" title="Learn how to create an authentication middleware with a global route guard on Vue School">Learn how navigation guards works with a free lesson on Vue School</a></div>
1010

1111
You can register global before guards using `router.beforeEach`:
1212

@@ -100,20 +100,20 @@ Finally, you can directly define route navigation guards inside route components
100100
```js
101101
const Foo = {
102102
template: `...`,
103-
beforeRouteEnter (to, from, next) {
103+
beforeRouteEnter(to, from, next) {
104104
// called before the route that renders this component is confirmed.
105105
// does NOT have access to `this` component instance,
106106
// because it has not been created yet when this guard is called!
107107
},
108-
beforeRouteUpdate (to, from, next) {
108+
beforeRouteUpdate(to, from, next) {
109109
// called when the route that renders this component has changed.
110110
// This component being reused (by using an explicit `key`) in the new route or not doesn't change anything.
111111
// For example, for a route with dynamic params `/foo/:id`, when we
112112
// navigate between `/foo/1` and `/foo/2`, the same `Foo` component instance
113113
// will be reused (unless you provided a `key` to `<router-view>`), and this hook will be called when that happens.
114114
// has access to `this` component instance.
115115
},
116-
beforeRouteLeave (to, from, next) {
116+
beforeRouteLeave(to, from, next) {
117117
// called when the route that renders this component is about to
118118
// be navigated away from.
119119
// has access to `this` component instance.
@@ -133,7 +133,7 @@ beforeRouteEnter (to, from, next) {
133133
}
134134
```
135135

136-
Note that `beforeRouteEnter` is the only guard that supports passing a callback to `next`. For `beforeRouteUpdate` and `beforeRouteLeave`, `this` is already available, so passing a callback is unnecessary and therefore *not supported*:
136+
Note that `beforeRouteEnter` is the only guard that supports passing a callback to `next`. For `beforeRouteUpdate` and `beforeRouteLeave`, `this` is already available, so passing a callback is unnecessary and therefore _not supported_:
137137

138138
```js
139139
beforeRouteUpdate (to, from, next) {
@@ -162,7 +162,7 @@ If you are using mixins that add in-component navigation guards, make sure to ad
162162
Vue.use(Router)
163163

164164
Vue.mixin({
165-
beforeRouteUpdate(to, from ,next) {
165+
beforeRouteUpdate(to, from, next) {
166166
// ...
167167
}
168168
})

docs/guide/advanced/scroll-behavior.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Scroll Behavior
22

3-
<div class="vueschool"><a href="https://vueschool.io/lessons/how-to-control-the-scroll-behavior-of-vue-router?friend=vuejs" target="_blank" rel="sponsored noopener" title="Learn how to control the scroll behavior on Vue School">Learn to control the scroll behavior with a free lesson on Vue School</a></div>
3+
<div class="vueschool"><a href="https://vueschool.io/lessons/how-to-control-the-scroll-behavior-of-vue-router?friend=vuerouter" target="_blank" rel="sponsored noopener" title="Learn how to control the scroll behavior on Vue School">Learn to control the scroll behavior with a free lesson on Vue School</a></div>
44

55
When using client-side routing, we may want to scroll to top when navigating to a new route, or preserve the scrolling position of history entries just like real page reload does. `vue-router` allows you to achieve these and even better, allows you to completely customize the scroll behavior on route navigation.
66

77
**Note: this feature only works if the browser supports `history.pushState`.**
88

99
When creating the router instance, you can provide the `scrollBehavior` function:
1010

11-
``` js
11+
```js
1212
const router = new VueRouter({
1313
routes: [...],
1414
scrollBehavior (to, from, savedPosition) {
@@ -28,7 +28,7 @@ If a falsy value or an empty object is returned, no scrolling will happen.
2828

2929
For example:
3030

31-
``` js
31+
```js
3232
scrollBehavior (to, from, savedPosition) {
3333
return { x: 0, y: 0 }
3434
}
@@ -38,7 +38,7 @@ This will simply make the page scroll to top for all route navigations.
3838

3939
Returning the `savedPosition` will result in a native-like behavior when navigating with back/forward buttons:
4040

41-
``` js
41+
```js
4242
scrollBehavior (to, from, savedPosition) {
4343
if (savedPosition) {
4444
return savedPosition
@@ -50,7 +50,7 @@ scrollBehavior (to, from, savedPosition) {
5050

5151
If you want to simulate the "scroll to anchor" behavior:
5252

53-
``` js
53+
```js
5454
scrollBehavior (to, from, savedPosition) {
5555
if (to.hash) {
5656
return {
@@ -69,7 +69,7 @@ We can also use [route meta fields](meta.md) to implement fine-grained scroll be
6969
7070
You can also return a Promise that resolves to the desired position descriptor:
7171

72-
``` js
72+
```js
7373
scrollBehavior (to, from, savedPosition) {
7474
return new Promise((resolve, reject) => {
7575
setTimeout(() => {

docs/guide/advanced/transitions.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Transitions
22

3-
<div class="vueschool"><a href="https://vueschool.io/lessons/how-to-create-route-transitions-with-vue-router?friend=vuejs" target="_blank" rel="sponsored noopener" title="Learn how to create route transitions on Vue School">Learn how to create route transitions with a free lesson on Vue School</a></div>
3+
<div class="vueschool"><a href="https://vueschool.io/lessons/how-to-create-route-transitions-with-vue-router?friend=vuerouter" target="_blank" rel="sponsored noopener" title="Learn how to create route transitions on Vue School">Learn how to create route transitions with a free lesson on Vue School</a></div>
44

55
Since the `<router-view>` is essentially a dynamic component, we can apply transition effects to it the same way using the `<transition>` component:
66

7-
``` html
7+
```html
88
<transition>
99
<router-view></router-view>
1010
</transition>
@@ -16,7 +16,7 @@ Since the `<router-view>` is essentially a dynamic component, we can apply trans
1616

1717
The above usage will apply the same transition for all routes. If you want each route's component to have different transitions, you can instead use `<transition>` with different names inside each route component:
1818

19-
``` js
19+
```js
2020
const Foo = {
2121
template: `
2222
<transition name="slide">
@@ -38,14 +38,14 @@ const Bar = {
3838

3939
It is also possible to determine the transition to use dynamically based on the relationship between the target route and current route:
4040

41-
``` html
41+
```html
4242
<!-- use a dynamic transition name -->
4343
<transition :name="transitionName">
4444
<router-view></router-view>
4545
</transition>
4646
```
4747

48-
``` js
48+
```js
4949
// then, in the parent component,
5050
// watch the `$route` to determine the transition to use
5151
watch: {

docs/guide/essentials/dynamic-matching.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Dynamic Route Matching
22

3-
<div class="vueschool"><a href="https://vueschool.io/lessons/vue-router-dynamic-routes?friend=vuejs" target="_blank" rel="sponsored noopener" title="Learn how to match dynamic routes with Vue School">Learn how to match dynamic routes with a free lesson on Vue School</a></div>
3+
<div class="vueschool"><a href="https://vueschool.io/lessons/vue-router-dynamic-routes?friend=vuerouter" target="_blank" rel="sponsored noopener" title="Learn how to match dynamic routes with Vue School">Learn how to match dynamic routes with a free lesson on Vue School</a></div>
44

55
Very often we will need to map routes with the given pattern to the same component. For example we may have a `User` component which should be rendered for all users but with different user IDs. In `vue-router` we can use a dynamic segment in the path to achieve that:
66

@@ -60,7 +60,7 @@ Or, use the `beforeRouteUpdate` [navigation guard](../advanced/navigation-guards
6060
```js
6161
const User = {
6262
template: '...',
63-
beforeRouteUpdate (to, from, next) {
63+
beforeRouteUpdate(to, from, next) {
6464
// react to route changes...
6565
// don't forget to call next()
6666
}

docs/guide/essentials/named-routes.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Named Routes
22

3-
<div class="vueschool"><a href="https://vueschool.io/lessons/vue-router-named-routes-and-params?friend=vuejs" target="_blank" rel="sponsored noopener" title="Learn how to work with named routes and params with Vue School">Learn how to use named routes and params with a free lesson on Vue School</a></div>
3+
<div class="vueschool"><a href="https://vueschool.io/lessons/vue-router-named-routes-and-params?friend=vuerouter" target="_blank" rel="sponsored noopener" title="Learn how to work with named routes and params with Vue School">Learn how to use named routes and params with a free lesson on Vue School</a></div>
44

55
Sometimes it is more convenient to identify a route with a name, especially when linking to a route or performing navigations. You can give a route a name in the `routes` options while creating the Router instance:
66

7-
``` js
7+
```js
88
const router = new VueRouter({
99
routes: [
1010
{
@@ -18,14 +18,14 @@ const router = new VueRouter({
1818

1919
To link to a named route, you can pass an object to the `router-link` component's `to` prop:
2020

21-
``` html
21+
```html
2222
<router-link :to="{ name: 'user', params: { userId: 123 }}">User</router-link>
2323
```
2424

2525
This is the exact same object used programmatically with `router.push()`:
2626

27-
``` js
28-
router.push({ name: 'user', params: { userId: 123 }})
27+
```js
28+
router.push({ name: 'user', params: { userId: 123 } })
2929
```
3030

3131
In both cases, the router will navigate to the path `/user/123`.

docs/guide/essentials/nested-routes.md

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Nested Routes
22

3-
<div class="vueschool"><a href="https://vueschool.io/lessons/vue-router-nested-routes?friend=vuejs" target="_blank" rel="sponsored noopener" title="Learn how to work with nested routes with Vue School">Learn how to work with nested routes with a free lesson on Vue School</a></div>
3+
<div class="vueschool"><a href="https://vueschool.io/lessons/vue-router-nested-routes?friend=vuerouter" target="_blank" rel="sponsored noopener" title="Learn how to work with nested routes with Vue School">Learn how to work with nested routes with a free lesson on Vue School</a></div>
44

55
Real app UIs are usually composed of components that are nested multiple levels deep. It is also very common that the segments of a URL corresponds to a certain structure of nested components, for example:
66

@@ -19,27 +19,25 @@ With `vue-router`, it is very simple to express this relationship using nested r
1919

2020
Given the app we created in the last chapter:
2121

22-
``` html
22+
```html
2323
<div id="app">
2424
<router-view></router-view>
2525
</div>
2626
```
2727

28-
``` js
28+
```js
2929
const User = {
3030
template: '<div>User {{ $route.params.id }}</div>'
3131
}
3232

3333
const router = new VueRouter({
34-
routes: [
35-
{ path: '/user/:id', component: User }
36-
]
34+
routes: [{ path: '/user/:id', component: User }]
3735
})
3836
```
3937

4038
The `<router-view>` here is a top-level outlet. It renders the component matched by a top level route. Similarly, a rendered component can also contain its own, nested `<router-view>`. For example, if we add one inside the `User` component's template:
4139

42-
``` js
40+
```js
4341
const User = {
4442
template: `
4543
<div class="user">
@@ -52,10 +50,12 @@ const User = {
5250

5351
To render components into this nested outlet, we need to use the `children` option in `VueRouter` constructor config:
5452

55-
``` js
53+
```js
5654
const router = new VueRouter({
5755
routes: [
58-
{ path: '/user/:id', component: User,
56+
{
57+
path: '/user/:id',
58+
component: User,
5959
children: [
6060
{
6161
// UserProfile will be rendered inside User's <router-view>
@@ -81,15 +81,16 @@ As you can see the `children` option is just another Array of route configuratio
8181

8282
At this point, with the above configuration, when you visit `/user/foo`, nothing will be rendered inside `User`'s outlet, because no sub route is matched. Maybe you do want to render something there. In such case you can provide an empty subroute path:
8383

84-
``` js
84+
```js
8585
const router = new VueRouter({
8686
routes: [
8787
{
88-
path: '/user/:id', component: User,
88+
path: '/user/:id',
89+
component: User,
8990
children: [
9091
// UserHome will be rendered inside User's <router-view>
9192
// when /user/:id is matched
92-
{ path: '', component: UserHome },
93+
{ path: '', component: UserHome }
9394

9495
// ...other sub routes
9596
]

docs/guide/essentials/passing-props.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Passing Props to Route Components
22

3-
<div class="vueschool"><a href="https://vueschool.io/lessons/how-to-pass-vue-router-params-as-props-to-components?friend=vuejs" target="_blank" rel="sponsored noopener" title="Learn how to pass props to route components with Vue School">Learn how to pass props to route components with a free lesson on Vue School</a></div>
3+
<div class="vueschool"><a href="https://vueschool.io/lessons/how-to-pass-vue-router-params-as-props-to-components?friend=vuerouter" target="_blank" rel="sponsored noopener" title="Learn how to pass props to route components with Vue School">Learn how to pass props to route components with a free lesson on Vue School</a></div>
44

55
Using `$route` in your component creates a tight coupling with the route which limits the flexibility of the component as it can only be used on certain URLs.
66

docs/ja/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ actionLink: /ja/installation.html
66
footer: MIT Licensed | Copyright © 2014-present Evan You, Eduardo San Martin Morote
77
---
88

9-
<div class="vueschool"><a href="https://vueschool.io/courses/vue-router-for-everyone?friend=vuejs" target="_blank" rel="sponsored noopener" title="Learn how to build powerful Single Page Applications with the Vue Router on Vue School">Watch a free video course about Vue Router on Vue School</a></div>
9+
<div class="vueschool"><a href="https://vueschool.io/courses/vue-router-for-everyone?friend=vuerouter" target="_blank" rel="sponsored noopener" title="Learn how to build powerful Single Page Applications with the Vue Router on Vue School">Watch a free video course about Vue Router on Vue School</a></div>
1010

1111
Vue Router は [Vue.js](http://vuejs.org) 公式ルータです。これは Vue.js のコアと深く深く統合されており、Vue.js でシングルページアプリケーションを構築します。機能は次の通りです:
1212

docs/ja/guide/README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# はじめに
22

33
::: tip Note
4-
ガイド内のコードのサンプルは [ES2015](https://github.com/lukehoban/es6features) を使っています。
4+
ガイド内のコードのサンプルは [ES2015](https://github.com/lukehoban/es6features) を使っています。
55

66
すべての example では、vue の完全バージョンを使用してテンプレートを解析可能にしています。詳細は[こちら](https://jp.vuejs.org/v2/guide/installation.html#ランタイム-コンパイラとランタイム限定の違い)を参照してください。
77
:::
88

9-
<div class="vueschool"><a href="https://vueschool.io/courses/vue-router-for-everyone?friend=vuejs" target="_blank" rel="sponsored noopener" title="Learn how to build powerful Single Page Applications with the Vue Router on Vue School">Watch a free video course about Vue Router on Vue School</a></div>
9+
<div class="vueschool"><a href="https://vueschool.io/courses/vue-router-for-everyone?friend=vuerouter" target="_blank" rel="sponsored noopener" title="Learn how to build powerful Single Page Applications with the Vue Router on Vue School">Watch a free video course about Vue Router on Vue School</a></div>
1010

1111
Vue.js と vue-router を使ったシングルページアプリケーションの構築は驚くほど簡単です。Vue.js のコンポーネントを使ってアプリケーションを既に構成しています。vue-router を混ぜ込むには、コンポーネントとルートをマッピングさせて vue-router にどこで描画するかを知らせるだけです。以下が基本的な例です。
1212

1313
## HTML
1414

15-
``` html
15+
```html
1616
<script src="https://unpkg.com/vue/dist/vue.js"></script>
1717
<script src="https://unpkg.com/vue-router/dist/vue-router.js"></script>
1818

@@ -33,7 +33,7 @@ Vue.js と vue-router を使ったシングルページアプリケーション
3333

3434
## JavaScript
3535

36-
``` js
36+
```js
3737
// 0. モジュールシステムを使っている場合 (例: vue-cli 経由で)、Vue と VueRouter をインポートし、`Vue.use(VueRouter)` を呼び出します。
3838

3939
// 1. ルートコンポーネントを定義します
@@ -74,7 +74,7 @@ const app = new Vue({
7474
// Home.vue
7575
export default {
7676
computed: {
77-
username () {
77+
username() {
7878
// `params` が表示される
7979
return this.$route.params.username
8080
}

0 commit comments

Comments
 (0)