Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs react路由器v4添加查询参数_Reactjs_React Router - Fatal编程技术网

Reactjs react路由器v4添加查询参数

Reactjs react路由器v4添加查询参数,reactjs,react-router,Reactjs,React Router,我正在为react应用程序使用react路由器v4 在表单中,我想在onSubmit操作上添加查询参数 我的代码如下所示: class FiltroCuentasCorrientes extends Component { ...//Other stuff. onSubmit(e) { e.preventDefault(); const { someVariable, otherVariable } = this.state; //Here I should add th

我正在为react应用程序使用react路由器v4

在表单中,我想在onSubmit操作上添加查询参数

我的代码如下所示:

class FiltroCuentasCorrientes extends Component {
 ...//Other stuff.

 onSubmit(e) {
   e.preventDefault();
   const { someVariable, otherVariable } = this.state;
   //Here I should add the variables to the query param.
 }

 render() {
  <Form onSubmit={(e) => this.onSubmit(e)}>
    ...
  </Form>
  }
}
类filterocurentascorrientes扩展组件{
……其他的东西。
提交(e){
e、 预防默认值();
const{someVariable,otherVariable}=this.state;
//在这里,我应该将变量添加到查询参数中。
}
render(){
此.onSubmit(e)}>
...
}
}
我不知道推荐的方法是什么

我是否应该在本地状态中设置一个变量,如
shouldAddParam
,并使用我的参数呈现一个

或者使用
路由器
上下文和
导航到
方法


如何才能做到这一点?

如果可能的话,我会在
render()
过程中尝试组合
form
元素的
action
属性。这样就没有必要防止违约

然而,如果您想使用React路由器“以编程方式重定向”,那么是的,您应该使用

this.context.router.push(path)

。。。正如您在中所看到的。

如果可能的话,我会在
render()
期间尝试组合
表单
元素的
操作
属性。这样就没有必要防止违约

然而,如果您想使用React路由器“以编程方式重定向”,那么是的,您应该使用

this.context.router.push(path)
。。。正如你在书中看到的