一键调用如何调用多功能

时间:2019-06-20 13:10:10

标签: reactjs

只需在React js中一键调用函数

handleProjectSelection = (v1, v2) => () => {
    console.log(`${v1} and ${v2}`)
}
anotherfunctionCall = (ss) => () => {
    console.log(ss) 
}
<p onClick={() => { this.handleProjectSelection("sdsdsd", 'dksdsd'); this.anotherfunctionCall("second");}}> click event </p>

如果有两个带有双箭头的功能,那么我想在一次单击中同时调用它们

2 个答案:

答案 0 :(得分:1)

您仅需使用one箭头功能即可调用onClick事件。

handleProjectSelection = (v1, v2) => {
    console.log(`${v1} and ${v2}`)
}
anotherfunctionCall = (ss) => {
    console.log(ss) 
}
<p onClick={() => { this.handleProjectSelection("sdsdsd", 'dksdsd'); this.anotherfunctionCall("second");}}> click event </p>

答案 1 :(得分:0)

 handleOnClick = (v1,v2,ss) {
   handleProjectSelection(v1,v2);
   anotherfunctionCall(ss);
}

<p onClick={() =>{ this.handleOnClick("sdsdsd", 'dksdsd',"second")> click event </p>