Ish*_*jaz 7 reactjs react-router react-router-dom
我在React-JS中使用React-Router:
这<Route>是一个内置组件,有两个不同的道具:
exact和strict
问题
该文件并没有明确的定义之间的差异exact和strict.
请帮助我.该文件非常令人困惑,当时还不清楚.
Bho*_*yar 21
如果你使用exact和strict在一起,然后location.pathname将只在路径道具提供完全匹配.
例:
<Route exact strict path="/one" component={About}/>
Run Code Online (Sandbox Code Playgroud)
只会匹配/one但不会/one/和/one/two.
例:
<Route exact strict path="/one/" component={About}/>
Run Code Online (Sandbox Code Playgroud)
只会匹配/one/但不会/one和/one/two.
如果仅使用strict,则location.pathname匹配具有尾部斜杠的匹配.
例:
<Route strict path="/one/" component={About}/>
Run Code Online (Sandbox Code Playgroud)
会匹配/one/,/one/two但不会/one.
如果仅使用exact,location.pathname则将匹配确切的位置路径.
例:
<Route exact path="/one" component={About}/>
Run Code Online (Sandbox Code Playgroud)
会匹配/one还是/one/.该exact道具不关心斜线.但它不会匹配/one/two.
| 归档时间: |
|
| 查看次数: |
3416 次 |
| 最近记录: |