1
1
# Nested Routes
2
2
3
- Mapping nested routes to nested components is a common need, and it is also very simple with vue-router.
3
+ ネストされた routes をネストされたコンポーネントにマッピングすることは共通の要求であり、そしてそれは vue-router では非常に簡単です。
4
4
5
- Suppose we have the following app:
5
+ 以下の app があると仮定します :
6
6
7
7
``` html
8
8
<div id =" app" >
9
9
<router-view ></router-view >
10
10
</div >
11
11
```
12
12
13
- The ` <router-view> ` here is a top-level outlet. It renders the component matched by a top level route:
13
+ ` <router-view> ` はここではトップレベルの outlet です。トップレベルの route でマッチしたコンポーネントでレンダリングします :
14
14
15
15
``` js
16
16
router .map ({
17
17
' /foo' : {
18
- // Foo is rendered when /foo is matched
18
+ // Foo は /foo がマッチしたとき、レンダリングされます
19
19
component: Foo
20
20
}
21
21
})
22
22
```
23
23
24
- Similarly, a rendered component can also contain its own, nested ` <router-view> ` . For example, if we add one inside the ` Foo ` component's template :
24
+ 同様に、レンダリングされたコンポーネントは、独自のネストされた ` <router-view> ` を含むことができます。例えば、もし ` Foo ` コンポーネントのテンプレート内部に1つ追加する場合 :
25
25
26
26
``` js
27
27
var Foo = Vue .extend ({
@@ -33,47 +33,47 @@ var Foo = Vue.extend({
33
33
})
34
34
```
35
35
36
- To render components into this nested outlet, we need to update our route config :
36
+ このネストされた outlet でコンポーネントをレンダリングするため、我々の route 設定を更新する必要あります :
37
37
38
38
``` js
39
39
router .map ({
40
40
' /foo' : {
41
41
component: Foo,
42
- // add a subRoutes map under /foo
42
+ // /foo のもとに subRoutes マップを追加
43
43
subRoutes: {
44
44
' /bar' : {
45
- // Bar will be rendered inside Foo's <router-view>
46
- // when /foo/bar is matched
45
+ // /foo/bar がマッチしたとき、
46
+ // Bar は Foo の <router-view> 内部でレンダリングされます
47
47
component: Bar
48
48
},
49
49
' /baz' : {
50
- // Same for Baz, but only when /foo/baz is matched
50
+ // Baz に対しても同じですが、 /foo/baz がマッチしたときです
51
51
component: Baz
52
52
}
53
53
}
54
54
}
55
55
})
56
56
```
57
57
58
- Now, with the above configuration, when you visit ` /foo ` , nothing will be rendered inside ` Foo ` 's outlet, because no sub route is matched. Maybe you do want to render something there. In such case you can provide a ` / ` subroute in this case:
58
+ 今、上記設定で、 ` /foo ` にアクセスするとき、サブ route がマッチされないため、 ` Foo ` の outlet 内部では何もレンダリングされません。恐らく、そこに何かレンダリングしたいです。このようなケースは、このケースの ` / ` サブ route 提供することができます。
59
59
60
60
``` js
61
61
router .map ({
62
62
' /foo' : {
63
63
component: Foo,
64
64
subRoutes: {
65
65
' /' : {
66
- // This component will be rendered into Foo's <router-view>
67
- // when /foo is matched. Using an inline component definition
68
- // here for convenience.
66
+ // このコンポーネントは /foo がマッチされるとき、
67
+ // Foo の <router-view> でレンダリングされます。
68
+ // 便宜上、ここでインラインコンポーネント定義を使用します。
69
69
component: {
70
70
template: ' <p>Default sub view for Foo</p>'
71
71
}
72
72
},
73
- // other sub routes...
73
+ // 他のサブ routes ...
74
74
}
75
75
}
76
76
})
77
77
```
78
78
79
- A working demo of this example can be found [ here ] ( http://jsfiddle.net/yyx990803/naeg67da/ ) .
79
+ この例の動作デモは [ ここ ] ( http://jsfiddle.net/yyx990803/naeg67da/ ) で見つけることができます。
0 commit comments