URL的查询字符串不匹配react-router路由
URL with query string not matching react-router route
给定这个React路由器配置:
<Router history={browserHistory}>
<Route path="/farm/:type?period=:period" component={Farm} />
<Route path="/pen/:penId" component={Pen} />
<Route path="/pen/:penId/cow/:cowId" component={Cow} />
<Route path="*" component={Farm} />
</Router>
为什么http://localhost:8080/farm/average?period=day
只匹配全能路由而不匹配第一条路由?
查询字符串参数不需要包含在<Route>
定义中。
修改路由定义为<Route path="/farm/:type" component={Farm} />
问题解决了
查询字符串参数在props.location.query
相关文章:
- React Router一直给我一个警告:你不能更改<路由器路由>
- 使用react router/react router redux将特定的redux操作绑定到一个路由
- React Router,在params之后嵌套路由
- 直接使用 React Router + React + Flux 路由到 URL
- 对不同的路由使用相同的组件与 React Router
- 如何使用 react-router 2 作为 expressjs 的服务器端路由
- 在 React Router 中,我如何路由到 2 个具有不同参数的相似 url
- react-router / redux-simple router 加载深度路由
- 如何在react router 1中获取活动路由路径名
- react router 1.0路由被express.js服务器获取
- React-Router使用jQuery导航路由
- React-router路由有多个子节点
- 多个react-router-relay路由使用相同的Relay根查询,但分片字段不同
- 在新项目上安装react-router后,使用它进行基本路由的问题
- 在React Router /browserHistory中获取当前路由的路径名
- Redux中的React Router路由参数
- React Router只识别索引路由
- 如何用Mobservable、React和可能的React- router做url/view路由
- URL的查询字符串不匹配react-router路由
- 防止React Router路由服务器API路径