Tom*_*zyk 1 reactjs react-router
用户收到带有邀请码的电子邮件,例如邀请码http://website.com/invitation/%s在哪里%s.
现在我想在我的应用程序中重定向该URL,但保留邀请代码如:
<Redirect from="/invitation/:code" to="/auth/register/:code" />
Run Code Online (Sandbox Code Playgroud)
因此,当用户点击电子邮件中的链接时:
http://website.com/invitation/2abc433
他将被转移到:
http://website.com/auth/register/2abc433
不幸的是,使用上面的Redirect组件,他被转移到了
http://website.com/auth/register/:code
您可以使用无状态组件:
<Route exact path="/invitation/:code" render={props => (
<Redirect to={`/auth/register/${props.match.params.code}`/>
)}/>
Run Code Online (Sandbox Code Playgroud)
<Redirect> 不支持直接传递参数的方法.
演示:https://codesandbox.io/s/8kjq4r1m90
| 归档时间: |
|
| 查看次数: |
2445 次 |
| 最近记录: |