2017-02-24 189 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