【发布时间】:2020-11-17 13:51:14
【问题描述】:
我在 react js 中需要语法帮助,
我希望在路径中实现这样的目标
http://localhost:3000/verify-email?key=ffdffae0237c43e6572bca3a3867eda1&eid=c2Frc2hpN0BnbWFpbC5jb20=
以下代码不起作用
<Route name="businessInformation" exact path="/verify-email?key=:someRandomKey&eid=:someRandomKey"> //Need help here
虽然,这适用于http://localhost:3000/verify-email/:key/:eid
<Route name="businessInformation" exact path="/verify-email/key/eid">
我应该如何附加这样的字符串值以便它理解?
【问题讨论】:
-
因为如果你想将参数传递给路径,只需写
/:paramName。在您的代码中,您还可以编写它的值。请在此处查看其文档:reactrouter.com/web/api/Route/path-string-string -
我想实现这样的目标,而不是 /verify-email?key=:someRandomKey&eid=:someRandomEmailKey 我该怎么做?其中动态值为 someRandomKey 和 someRandomEmailKey
标签: reactjs react-router