Reactjs 带标签的动态响应路由器
我有一个带有表格的页面,在其中单击Reactjs 带标签的动态响应路由器,reactjs,react-router,react-router-v4,react-router-dom,Reactjs,React Router,React Router V4,React Router Dom,我有一个带有表格的页面,在其中单击,用户将被重定向到另一个页面,如下所示: // parent component <tr onClick={() => this.props.history.push(`users/${id}`)}> 我怎样才能达到这个结果? 谢谢!:) 如果您将路线定义为 /users/:userId /info/:userId 您可以从params读取userID,并使用它在页面之间导航 <Tab label='Info' key='info'&
,用户将被重定向到另一个页面,如下所示:
// parent component
<tr onClick={() => this.props.history.push(`users/${id}`)}>
我怎样才能达到这个结果?
谢谢!:) 如果您将路线定义为
/users/:userId
/info/:userId
您可以从params读取userID,并使用它在页面之间导航
<Tab label='Info' key='info'>
<Redirect to={`/info/${this.match.params.userId}`} />
</Tab>
我尝试了类似的方法,但url显示类似于idk的内容为什么:info/:id12345
。然后当我从[info tab]
转到[users tab]
时,url看起来像用户/:id:id12345
你可能正在写
你需要写
现在是这样的:
,其中routes.info是/info/:id
,如果我从/info//code>中删除:id
,url看起来像/info/12345
,但我看不到信息页面的内容。export-const-USERS='/USERS/:id'export-const-info='/info/'export-const-PARENT='/PARENT'
/users/:userId
/info/:userId
<Tab label='Info' key='info'>
<Redirect to={`/info/${this.match.params.userId}`} />
</Tab>