8000 docs(ja): update dynamic-matching.md · vuejs/vue-router@873f868 · GitHub
[go: up one dir, main page]

Skip to content

Commit 873f868

Browse files
committed
docs(ja): update dynamic-matching.md
ref: f4d1866
1 parent 10381ee commit 873f868

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

docs/ja/guide/essentials/dynamic-matching.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,35 @@ const User = {
6565
}
6666
```
6767

68+
## Catch all / 404 Not found Route
69+
70+
Regular params will only match characters in between url fragments, separated by `/`. If we want to match **anything**, we can use the asterisk (`*`):
71+
72+
```js
73+
{
74+
// will match everything
75+
path: '*'
76+
}
77+
{
78+
// will match anything starting with `/user-`
79+
path: '/user-*'
80+
}
81+
```
82+
83+
When using _asterisk_ routes, make sure to correctly order your routes so that _asterisk_ ones are at the end.
84+
The route `{ path; '*' }` is usually used to 404 client side. If you are using _History mode_, make sure to [correctly configure your server](./history-mode.md) as well.
85+
86+
When using an _asterisk_, a param named `pathMatch` is automatically added to `$route.params`. It contains the rest of the url matched by the _asterisk_:
87+
88+
```js
89+
// Given a route { path: '/user-*' }
90+
this.$router.push('/user-admin')
91+
this.$route.params.pathMatch // 'admin'
92+
// Given a route { path: '*' }
93+
this.$router.push('/non-existing')
94+
this.$route.params.pathMatch // '/non-existing'
95+
```
96+
6897
## 高度なマッチングパターン
6998

7099
`vue-router` はパスのマッチングエンジンとして [path-to-regexp](https://github.com/pillarjs/path-to-regexp) を使っています。これは Optional による動的なセグメント、Zero or more / One or more に対する要求、また、カスタム正規表現パターンまでもサポートしています。 これらの高度なパターンについてはこちらの [ドキュメンテーション](https://github.com/pillarjs/path-to-regexp#parameters) または、 `vue-router` の中でそれらを使っている [こちらの例](https://github.com/vuejs/vue-router/blob/dev/examples/route-matching/app.js) をご参照ください。

0 commit comments

Comments
 (0)
0