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>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章