React的事件传参

事件传参

  1. 方式一:通过bind传参
handle=(a,b,event)=>{
    console.log(a, b, event);
}
<button data-id="1001" onClick={this.handle.bind(this,1002,1003)}>点击</button>
  1. 方式二:通过箭头函数传参
handle=(a,b,event)=>{
    console.log(a, b, event);
}
<button data-id="1001" onClick={(event)=>{this.handle(1002,1003,event)}}>点击</button>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章