我正在使用React Router和Link来更改URL并浏览应用程序。在阅读列表中,我使用以下代码将用户导航到阅读编辑页面:
<Link to={`readings/edit/${reading.id}`} params={{id: reading.id}}>
我已定义了以下路由:
<Route path="/" component={App}>
<IndexRoute component={Greetings}/>
...
<Route path="readings/edit/:id" component={requireAuth(ReadingEdit)}/>
<Route path="readings/:tab" component={requireAuth(ReadingListContainer)}/>
...
</Route>
导航功能正常,但URL有误,应该是
http://localhost:8000/readings/edit/5
,但实际上是http://localhost:8000/readings/readings/edit/5
。这意味着当我刷新网站时,路由器找不到路径。如何解决这个问题?