Skip to content

Commit d1fb994

Browse files
authored
Merge pull request #55 from xiao2075/patch-1
Update RouteMatching.md
2 parents 3eb2f8e + e3855de commit d1fb994

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

docs/guides/basics/RouteMatching.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ React Router 使用路由嵌套的概念来让你定义 view 的嵌套集合,
1414

1515
- `:paramName` – 匹配一段位于 `/``?``#` 之后的 URL。 命中的部分将被作为一个[参数](/docs/Glossary.md#params)
1616
- `()` – 在它内部的内容被认为是可选的
17+
- `?` -内容是可选的
1718
- `*` – 匹配任意字符(非贪婪的)直到命中下一个字符或者整个 URL 的末尾,并创建一个 `splat` [参数](/docs/Glossary.md#params)
1819
- `**` - 匹配任意字符(贪婪的)直到命中下一个字符 `/``?``#`,并创建一个 `splat` [参数](/docs/Glossary.md#params)
1920

2021
```js
2122
<Route path="/hello/:name"> // 匹配 /hello/michael 和 /hello/ryan
2223
<Route path="/hello(/:name)"> // 匹配 /hello, /hello/michael 和 /hello/ryan
24+
<Route path="hello/:name?"> // 4.0以后 应该这样写 匹配/hello, /hello/michael 和 /hello/ryan
2325
<Route path="/files/*.*"> // 匹配 /files/hello.jpg 和 /files/path/to/hello.jpg
2426
```
2527

0 commit comments

Comments
 (0)