[英]React Router TransitionTo Missing Parameter
I am trying to programmatically redirect using React-router. 我正在尝试使用React-router以编程方式重定向。 However, I am stuck with an issue. 但是,我遇到了一个问题。
routes 路线
<Route handler={Home} path="/">
<Route handler={Handler2} name="route-2" path="/route2" />
<Route handler={Handler3} name="route-3" path="/route3/:param1" >
<Route handler={Handler4} name="route-4" path="subroute/:param2" />
</Route>
</Route>
A component Deep in the hierarchy, child of handler 一个组件,位于层次结构深处,是处理程序的子级
...
contextTypes: {
router: React.PropTypes.func
},
handleClick : function(e){
this.context.router.transitionTo('route-4',{param1:1,param2:2});
},
...
I am able to call the transitionTo function and also the right route, but I get the error saying, 我可以调用transitionTo函数,也可以调用正确的路由,但是却收到错误消息,
Invariant Violation: Missing "param1" parameter for path "/route3/:param1/subroute/:param2" 不变违规:路径“ / route3 /:param1 / subroute /:param2”缺少“ param1”参数
Please help. 请帮忙。 Is this a syntax error? 这是语法错误吗?
This might help you https://github.com/rackt/react-router/issues/1285#issuecomment-111908695 这可能会帮助您https://github.com/rackt/react-router/issues/1285#issuecomment-111908695
As Michael said you would need to: 正如迈克尔所说,您需要:
In order to interpolate params in the 0.13.x API your path needs to have a segment for that param to occupy. 为了在0.13.x API中插值参数,您的路径需要有一个细分以占用该参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.