React onClick - pass event with parameter

后端 未结 5 716
半阙折子戏
半阙折子戏 2020-12-22 17:33

Without Parameter

function clickMe(e){
  //e is the event
}


With Para

5条回答
  •  没有蜡笔的小新
    2020-12-22 17:55

    Solution 1

    function clickMe(parameter, event){
    }
    
    
    

    Solution 2 Using the bind function is considered better, than the arrow function way, in solution 1. Note, that the event parameter should be the last parameter in the handler function

    function clickMe(parameter, event){
    }
    
    
    

提交回复
热议问题