ReactJS - Is there a way to trigger a method by pressing the 'Enter' key inside <input/>?

前端 未结 4 718
长情又很酷
长情又很酷 2020-12-31 07:46

Using only onChange and value and while focused inside a , preferably without jQuery, is there a way to trigger a method by pressing

4条回答
  •  太阳男子
    2020-12-31 08:26

    Use onKeyPress and the resulting event object's key property, which is normalised cross-browser for you by React:

    
    
    
    
    
    

提交回复
热议问题