无参数
function clickMe(e){
//e is the event
}
<button onClick={this.clickMe}></button>
带参数
function clickMe(parameter){
//how to get the "e" ?
}
<button onClick={() => this.clickMe(someparameter)}></button>
我想要event
美元.我怎么才能拿到?
function clickMe(e){
//e is the event
}
<button onClick={this.clickMe}></button>
function clickMe(parameter){
//how to get the "e" ?
}
<button onClick={() => this.clickMe(someparameter)}></button>
我想要event
美元.我怎么才能拿到?
试试这个:
<button
onClick={(e) => {
this.clickMe(e, someParameter);
}}
>
Click Me!
</button>
在你的职能和职责中:
function clickMe(event, someParameter){
//do with event
}