如何使用带有Java的onClick调用2个函数

时间:2019-02-06 13:36:33

标签: javascript html reactjs

我有:

one = () => {
   //do something
}
two = () => {
   //do something
}

<div>
   <button onClick={/*this.one, this.two  (it doens't work)*/}>Go</button>
</div>

我如何仅使用一个onClick调用两个函数?

2 个答案:

答案 0 :(得分:-1)

尝试:

<div>
   <button onClick={this.one; this.two}>Go</button>
</div>

答案 1 :(得分:-1)

How to call multiple JavaScript functions in onclick event?

one = () => {
   //do something
}
two = () => {
   //do something
}

<div>
   <button onclick="one();two();">Go</button>
</div>