react-router - 创建没有组件嵌套的嵌套路由

react-router - creating nested routes with no Component nesting

我有这样的路由配置。

<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>