具有父路径路径参数的子路径

时间:2016-09-09 20:14:56

标签: reactjs react-router

我有以下内容:

<Route path="things/:id" component={...}>
  <Route path="thing-types" component={…} />
</Route>

当我构建<Link to="thing-types">时,我最终得到/things/thing-types而不是things/100/thing-types

1 个答案:

答案 0 :(得分:1)

原来<Link>并不像我想象的那么聪明。我不得不修改为:

<Link to={`/things/${thing.id}/thing-types`}>Thing Types</Link>