Warn and error errors encountered by Angular6

created at 07-07-2021 views: 4

description

[Violation] Added non-passive event listener to a scroll-blocking 'mousewheel' event. Consider marking event handler as 'passive' to make the page more responsive.

This is because after Chrome51, Chrome has added a new event capture mechanism-Passive Event Listeners

solution

Use addEventListener to tell chrome whether it is passive monitoring through the passive parameter. When the value of the attribute passive is true, it means that the listener will not call the preventDefault function to prevent the default sliding behavior, such as:

// Add {passive: true} to the listening event
document.addEventListener("mousewheel", fn, {passive: true})

// The way to close warn
npm i default-passive-events -s
// Add in the entry file
import'default-passive-events';
Please log in to leave a comment.