我有这样的路由配置。
<Route path="group/:groupId" component={NonPropertyView}>
<Route path="group/:groupId/line/:lineId" component={NonPropertyView} />
<Route path="group/:groupId/line/:lineId/property/:propertyId" component={PropertyView} />
但是我可以这样做吗?
<Route path="group/:groupId" component={NonPropertyView}>
<Route path="line/:lineId" component={NonPropertyView}>
<Route path="property/:propertyId" component={PropertyView} />
</Route>
</Route>
我正在寻找的是仅为Component
叶路线渲染而不渲染父路线的选项Component
。这可能吗?
是的-使用<IndexRoute>
s。例如,将上面的代码写为:
<Route path="group/:groupId">
<IndexRoute component={NonPropertyView} />
<Route path="line/:lineId">
<IndexRoute component={NonPropertyView} />
<Route path="property/:propertyId" component={PropertyView} />
</Route>
</Route>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句