0
我現在面臨的情況是,我有我的路由器工作正常進行以下配置所有可選參數:陣營路由器不匹配
<Route path="/" component={Blog}>
<Route path="list(/:category)(/:subcat)" component={ArticleList} />
<Route name="article/:category(/:subcat)/:id" component={ArticlePage} />
</Route>
但現在我被要求提高URL和刪除一些「 >所需的URL
博客/表/足球/世界盃 - - 從網址
當前URL不必要的」前綴>博客/足球/世界盃
博客/表/足球 - >博客/足球
博客/條/足球/ 10 - >博客/足球/ 10
所以我曾嘗試改變我的路線,以保持可選
所有參數<Route path="/" component={Blog}>
<Route path="(/:category)(/:subcat)" component={ArticleList} />
<Route name=":category(/:subcat)/:id" component={ArticlePage} />
</Route>
有沒有一種方法可以像使用反應路由器描述的那樣匹配網址?
您可以使用['' (https://github.com/ReactTraining/react-router/blob/master/docs/API.md#redirect)如果您需要保持目前的路線,但重定向到簡化版本。 –
feychou