路由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 :(得分:1)
交换这2行,
而不是:
<Route path="*" components={NotMatch}/>
<Route path="about-us" components={AboutUs}/>
使用此:
<Route path="about-us" components={AboutUs}/>
<Route path="*" components={NotMatch}/>
从路由:
和country
移除country/: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>
答案 1 :(得分:0)
感谢Mayank Shukla。你给了我正确的摩擦力。
<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>
这个工作。