我正在使用react-router 3.0.2并尝试使用查询字符串配置路由器路径 . 这就是我配置路由器的方式:
<Router history={browserHistory}>
<Route path="abc/login.do" component={LoginComponent}/>
<Route path="abc/publicLoginID.do?phase=def" component={VerifyComponent} />
<Route path="abc/publicLoginID.do?phase=ghi" component={ImageComponent}/>
<Route path="*" component={LoginComponent}/>
</Router>
我知道这不是在"Route"中指定查询字符串(?)的正确方法 . 如何确保每当用户输入“http://localhost:3000/abc/publicLoginID.do?phase=def " in the url, "验证组件" shows up, and when he enters " http://localhost:3000/abc/publicLoginID.do?phase=ghi " in the url, " ImageComponent”时 .
我在这里检查了一些案例:react-router match query string和Querystring in react-router,但无法弄清楚如何使其工作 .
1 回答
您可以编写一个包装器组件,它将根据查询参数切换要呈现的内容