[Violation] Added non-passive event listener to a scroll-blocking ‘mousewheel’ event. Consider marking event handler as ‘passive’ to make the page more responsive.
这是因为Chrome51版本以后,Chrome增加了新的事件捕获机制-Passive Event Listeners
使用addEventListener是通过passive参数来告诉chrome是否是被动监听,当属性passive的值为true的时候,代表该监听器内部不会调用preventDefault函数来阻止默认滑动行为,如:
// 给监听事件添加{passive: true}
document.addEventListener("mousewheel", fn, {passive: true})
// 关闭warn的办法
npm i default-passive-events -s
// 在入口文件中加入
import 'default-passive-events';