2017-04-05 60 views
0

路由about-us不起作用。只有当我在路由Country上附加一些前缀时才有效。我该如何解决它。谢谢。路由静态不起作用

<Route path="/" component={App}> 
    <IndexRoute components={Home}/> 
    <Route path=":country" components={Country}/> 
    <Route path=":country/:city" components={City}/> 
    <Route path="*" components={NotMatch}/> 
    <Route path="about-us" components={AboutUs}/> 
</Route> 

回答

0

感谢Mayank舒克拉。你给了我正确的偏见。

<Route path="/" component={App}> 
    <IndexRoute components={Home}/> 
    <Route path="/about-us" components={AboutUs}/> 
    <Route path=":country" components={Country}/> 
    <Route path=":country/:city" components={City}/> 
    <Route path="*" components={NotMatch}/> 
</Route> 

This working。

1

交换这两条线,

相反的:

<Route path="*" components={NotMatch}/> 
<Route path="about-us" components={AboutUs}/> 

使用此:

<Route path="about-us" components={AboutUs}/> 
<Route path="*" components={NotMatch}/> 

而且从路线countrycountry/:city删除:

像这样:

<Route path="/" component={App}> 
    <IndexRoute components={Home}/> 
    <Route path="country" components={Country}/> 
    <Route path="country/:city" components={City}/> 
    <Route path="about-us" components={AboutUs}/> 
    <Route path="*" components={NotMatch}/> 
</Route> 
+0

检查更新的答案:) –