File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change 2
2
3
3
## 公式ルータ
4
4
5
- ほとんどのシングルページアプリケーションでは、公式にサポートされている [ vue-router ライブラリ] ( https://github.com/vuejs/vue-router ) を使うことをオススメします。詳細は vue-router の[ ドキュメント] ( https://router.vuejs.org/ ) を参照してください。
5
+ ほとんどのシングルページアプリケーションでは、公式にサポートされている [ vue-router ライブラリ] ( https://github.com/vuejs/vue-router-next ) を使うことをオススメします。詳細は vue-router の[ ドキュメント] ( https://next. router.vuejs.org/ ) を参照してください。
6
6
7
7
## スクラッチからのシンプルなルーティング
8
8
9
9
とてもシンプルなルーティングだけが必要で、フル機能のルータライブラリを使用したくない場合は、以下のようにページレベルのコンポーネントで動的にレンダリングができます。
10
10
11
11
``` js
12
+ const { createApp , h } = Vue
13
+
12
14
const NotFoundComponent = { template: ' <p>Page not found</p>' }
13
15
const HomeComponent = { template: ' <p>Home page</p>' }
14
16
const AboutComponent = { template: ' <p>About page</p>' }
@@ -30,11 +32,11 @@ const SimpleRouter = {
30
32
},
31
33
32
34
render () {
33
- return Vue . h (this .CurrentComponent )
35
+ return h (this .CurrentComponent )
34
36
}
35
37
}
36
38
37
- Vue . createApp (SimpleRouter).mount (' #app' )
39
+ createApp (SimpleRouter).mount (' #app' )
38
40
```
39
41
40
42
[ History API] ( https://developer.mozilla.org/en-US/docs/Web/API/History_API/Working_with_the_History_API ) と組み合わせることで、とても基本的ですが完全に機能するクライアント側のルータを構築できます。実際に確認するには、[ このサンプルアプリ] ( https://github.com/phanan/vue-3.0-simple-routing-example ) をチェックしてみてください。
You can’t perform that action at this time.
0 commit comments