Dra*_*scu 16 reactjs react-router
什么是使用的优势Match和Miss部件免受react-router过Router组件?我似乎无法在react-router docs中找到任何关于此的文档.
我的问题来自于反应 - 通用样板,更准确地说,通过查看这里:https://github.com/ctrlplusb/react-universally
Pau*_*l S 41
<Match>并且<Miss>是React Router v4的alpha版本中的组件.
在测试中,<Match>已经重命名<Route>(并且它的道具已经改变,所以 pattern现在path和exactly是exact).该<Miss>组件完全被移除.相反,你应该使用一个<Switch>语句,它只会渲染匹配的第一个<Route>(或<Redirect>).您可以添加无路径组件作为<Switch>路由的最后一个子组件,并且当前面的s都不<Route>匹配时它将呈现.
您可以查看API文档以获取更多详细信息.
<Switch>
<Route exact path='/' component={Home} />
<Route path='/about' component={About} />
// The following <Route> has no path, so it will always
// match. This means that <NoMatch> will render when none
// of the other <Route>s match the current location.
<Route component={NoMatch} />
</Switch>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5214 次 |
| 最近记录: |