没有“/”的 ReactJS 动态路由

ReactJS dynamic route without "/"

我正在用户点击系统生成的电子邮件验证 link 即:www.mydomain.com/verify?token=982db6fefde1fb 使用 <Route path="verify?token=:id" component={Verify} /> 但如果没有,我似乎无法使用动态 ID /:id 之前抛出路由器错误

Warning: [react-router] Location "/verify?token=982db6fefde1fb25cc0a8cd82dae783ff5519b3f023463c1" did not match any routes.

如何在不使用 / 的情况下创建动态 :id 路线?

一样定义路由
<Route path="verify" component={Verify} />

现在在 Verify 组件中,您可以获取查询参数,例如

this.props.location.query.token