[英]multiple component react router
我正在建立一個反應應用程序的索引頁面。
索引頁面包含組件A和B,如果路由為“ / a”,那么我想用C切換B並顯示A和C。對於其他路由“ / a / b” ,我想顯示其他頁面。
我已經嘗試了以下方法,但是它不起作用:
<Route path="/" component={App}>
<IndexRoute component={A} >
<IndexRoute component={B}/>
<Route path="/a" component={C} />
</IndexRoute>
<Route path="/a/b" component={D} />
</Route>
謝謝!
我以非正式的方式解決。
<div>
<Redirect from="/" to="home"/>
<Route path="/" component={App}>
<Route path="home" component={Home}>
<IndexRoute component={IndexView} />
<Route path="other" component={OtherView}></Route>
</Route>
<Route path="about" component={About}></Route>
</Route>
</div>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.