获取 <Link> 反应路由器组件以计算相对于根域的 url

Getting the <Link> react router component to compute urls relative to root domain

在 goodsite.com 上,通过 React 路由器向用户显示 link...link 看起来像这样

<TableCell    
  component={Link} 
  to={`happy/${thing.id}`} 
 >
 {thing.name}
</TableCell>

此 link 位于 goodsite 的页面上。com/unhappy。

在这种结构下,当用户点击 link 时,他们会被带到

goodsite.com/unhappy/happy/dynamicallygenedthing

如何更改上面的 react-router 构造以确保用户最终达到以下 url

goodsite.com/happy/dynamicallygenedthing

正在尝试在 happy 前面添加正斜杠

到={**/**happy/${thing.id}}

好像不行...

事实证明,通过 React 路由器的 Link 组件获取相对 urls 很容易。以下路径

<TableCell    
  component={Link} 
  to={`../happy/${thing.id}`} 
 >
 {thing.name}
</TableCell>

已努力输出所需的 url

goodsite.com/happy/dynamicallygenedthing