0
嵌套航線指數的路線我計劃在我的應用程序下面的路線設置。我目前正在使用React-Router 2.7。在陣營路由器V3
/
/stored_systems
/stored_systems/schemas/:schema_id
/stored_systems/schemas/:schema_id/systems/:system_id
/runtime
/runtime/mainlines/:mainline_id
/runtime/mainlines/:mainline_id/valve_groups/:valve_group_id
我已經寫了路由器的配置如下。
<Route path='/' component={App}>
<IndexRoute component={StoredSystems} />
<Route path='/stored_systems' component={StoredSystems} >
<IndexRoute component={SchemasList} />
<Route path='/stored_systems/schemas/:schema_id' component={Schema} />
<Route path='/stored_systems/schemas/:schema_id/systems/:system_id' component={System} />
</Route>
<Route path='/runtime' component={Runtime} >
<IndexRoute component={MainLinesList} />
<Route path='/runtime/mainlines/:mainline_id' component={Mainline} />
<Route path='/runtime/mainlines/:mainline_id/valve_groups/:valve_group_id' component={ValveGroup} />
</Route>
</Route>
StoredSystems和Runtime是基本呈現{props.children}的無狀態組件。
現在,如果我去/ stored_systems,它會正確地呈現SchemasList組件。像/ stored_systems/schemas/schema1這樣的路線會正確渲染。
但是,如果我去/,它將使StoredSystems部件,沒有它的孩子。那麼,沒有定義任何子節點,因爲它正在加載IndexRoute。
如何使內部StoredSystems的SchemaList,當我瀏覽到根?
我認爲這將是更好地爲你改變你的成分,因爲你的要求均不會被設計完成。嘗試嘗試無路線路線。 –