反应路由器参数
React Router Param
是否可以用 React router 做到这一点?
<Route path="/:reset_password" component={ResetPassword} />
<Route path="/:create_password" component={CreatePassword}/>
我想对不同的组件使用不同的参数。我测试了上面的代码,但它不起作用。如果我改成这个,上面的代码就可以工作了:
<Route path="/something1/:reset_password" component={ResetPassword} />
<Route path="/something2/:create_password" component={CreatePassword}/>
感谢帮助
如@chris 所说,删除冒号 and/or 分配专用路由。 React Router 无法区分您提供的两条路由,因为它们在技术上是相同的(根路径 + 动态参数。)
是否可以用 React router 做到这一点?
<Route path="/:reset_password" component={ResetPassword} />
<Route path="/:create_password" component={CreatePassword}/>
我想对不同的组件使用不同的参数。我测试了上面的代码,但它不起作用。如果我改成这个,上面的代码就可以工作了:
<Route path="/something1/:reset_password" component={ResetPassword} />
<Route path="/something2/:create_password" component={CreatePassword}/>
感谢帮助
如@chris 所说,删除冒号 and/or 分配专用路由。 React Router 无法区分您提供的两条路由,因为它们在技术上是相同的(根路径 + 动态参数。)