Element UI Scroll Blocking Issue: 'mousewheel' Event Listener - How to Fix
This error message, 'element-ui.common.js:10016 [Violation]Added non-passive event listener to a scroll-blocking 'mousewheel' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952', indicates that a non-passive event listener has been added to the 'mousewheel' event within the Element UI library, causing a potential block to scrolling actions. Browsers recommend marking the event handler as 'passive' to improve the page's responsiveness.
To address this issue, follow these steps:
-
Locate the Code: Open the 'element-ui.common.js' file and locate the code on line 10016 where the event listener is added.
-
Add Passive Option: Above the line where you add the event listener, insert an options object with the 'passive' property set to true. This instructs the browser that the event listener won't prevent scrolling:
element.addEventListener('mousewheel', handler, { passive: true });
- Save and Reload: Save the changes to the 'element-ui.common.js' file and reload your webpage. The error should no longer appear.
Note that this error is a browser warning and doesn't affect the code's functionality. However, for optimal performance and user experience, it's recommended to address the browser's suggestion by using passive event listeners.
原文地址: https://www.cveoy.top/t/topic/pkwQ 著作权归作者所有。请勿转载和采集!