Home > front end >  How to solve the problem of global call enter events
How to solve the problem of global call enter events

Time:10-23

OnKeyPress=()=& gt; {
Document. The onkeydown=e=& gt; {
Let ev=document. All? Window. The event: e;
If (ev) keyCode===13) {
Enclosing searchFeedback ();
}
};
};
With the react framework
As shown in figure, wrote this method under the page, but press enter after switching to other pages or call the method, how to solve this global problem,

CodePudding user response:

Write in life cycle, loading when loading the incident, component destroyed before emptying the event

Document. The onkeydown=null


  • Related