2017-02-24 190 views
0

路由器NOMATCH路线我有这样的结构反应动态路由

<Route path="user"   component={Users}> 
 
    <Route path=":userId"  component={User}> 
 
    <Route path=":project" component={Project}/> 
 
    <Route path="*"   component={NotFound} /> 
 
    </Route> 
 
    <Route path="*" component={NotFound} /> 
 
</Route> 
 
<Route path="*" component={NotFound} />

不管我如何努力尝试设置<NoMatch />,我总是能获得通过url要么user idproject id这并不存在。我现在已经有两天了,这让我感到非常困惑,因为我迷失了互联网上不同的方法/答案,我感到非常困惑。

使用react-router v3.0.2

回答

0

编辑:我是完全错误的轨道上了。我的意思是,回退是未定义的路线,因此类似于/foo

/user/55user/55/project是有效的路由,即使您没有用户号。 55在你的数据库中 - 你不能在这里使用回退。

+0

我不能使用用户ID数组检查':userId'路径吗? – nehel

+0

我想你可以使用ID数组检查:userId路径,如果没有匹配,则重定向到notfound路由。 – paqash