使用有什么好处Match
and Miss
组件来自react-router
over Router
成分?我似乎找不到任何关于此的文档反应路由器文档 https://github.com/ReactTraining/react-router/tree/master/docs.
我的问题源于查看普遍反应 https://github.com/ctrlplusb/react-universally更准确地说,请查看此处的样板:https://github.com/ctrlplusb/react-universally https://github.com/ctrlplusb/react-universally
<Match>
and <Miss>
是 React Router v4 的 alpha 版本中的组件。
在测试版中,<Match>
已更名<Route>
(并且它的 props 已经改变,所以pattern
is now path
and exactly
is exact
). The <Miss>
组件被完全删除。相反,你应该使用<Switch>
语句,它只会渲染第一个<Route>
(or <Redirect>
)即匹配。您可以添加一个无路径组件作为该组件的最后一个子组件<Switch>
的路线,当前面没有一个时它将渲染<Route>
s match.
您可以查看API文档 https://reacttraining.com/react-router/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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)