problem description : when you click the return button, the following errors appear in the console each time:
mui.min.js:13 Unable to preventDefault inside passive event listener due to target being treated as passive.
solutions :
Locate the error line of mui.min.js, and find that the error code is a.preventdefault(), so comment out a.preventdefault() in mui.min.js, and the problem is solved
problem analysis :
What functions does the preventdefault() function implement?Is there any impact on the specific function of annotation
The preventdefault () method prevents elements from default behavior (for example, preventing the submission of forms when the submit button is clicked). For example, you can use event. Preventdefault() to prevent tag a from jumping
Because the browser can’t know in advance whether an event handler will call preventdefault (), it needs to wait until the event handler is executed before it can execute the default behavior. However, the execution of the event handler is time-consuming, which will cause the page to jam. That is to say, when the browser waits for the default behavior of the event to be executed, Most of the time it’s just waiting for nothing
If the web developer can tell the browser in advance that “ I don’t call the preventdefault function to prevent the event behavior “, then the browser can quickly generate events and improve the page performance. The proposal of passive event listeners solves this problem
In my project, I successfully solved the problem of console error reporting by commenting out preventdefault(), and I haven’t found any effect on other functions yet
Similar Posts:
- Unable to preventDefault inside passive event listener due to target being treated as passive?
- ”Cannot read property ‘addEventListener’ of null“
- The applet reports an error thirdscripterror DateValue is not defined;
- [How to Solve] Cannot set property ‘onclick’ of null
- How to Solve Error: Cannot set property ‘onclick’ of null
- Three common ways of react event binding and solution can’t update during an existing state transition (such as within ‘render’)
- event.srcElement And event.target The difference between
- The Difference between $(document).ready, window.onload and $(window).load(function (){})
- Error in JS function referencing public page [How to Solve]
- [Solved] Vue Axios error: TypeError: Cannot set property ‘tableData‘ of undefined