小编Isa*_*lla的帖子

如何在具有更多参数的函数中使用 e.preventDefault()?

我正在 React 中处理一个表单,我需要使用 event.preventDefault。同时我还需要向父函数传递其他参数。我尝试使用下面的代码正常添加它们,但似乎不起作用;我怎样才能做到这一点?我已经看过其他问题,但没有找到解决方案。

handleSubmit = (event, param1, param2) => {
    event.preventDefault();

    this.setState(prevState => {
        // piece of code where i need to use the other parameters    
   }); 
}
Run Code Online (Sandbox Code Playgroud)

javascript reactjs

3
推荐指数
2
解决办法
2035
查看次数

标签 统计

javascript ×1

reactjs ×1