vue开发:[Violation] Added non-passive event listener to a scroll-blocking event. Consider ma…

在基于 Element-ui 写项目的时候,Chrome 提醒:
[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;

Passive Event Listeners:就是告诉前页面内的事件监听器内部是否会调用preventDefault函数来阻止事件的默认行为,以便浏览器根据这个信息更好地做出决策来优化页面性能。当属性passive的值为true的时候,代表该监听器内部不会调用preventDefault函数来阻止默认滑动行为,Chrome浏览器称这类型的监听器为被动(passive)监听器。目前Chrome主要利用该特性来优化页面的滑动性能,所以Passive Event Listeners特性当前仅支持mousewheel/touch相关事件。


1.npm i default-passive-events -S

2.main.js中加入:import ‘default-passive-events’


9 thoughts on “vue开发:[Violation] Added non-passive event listener to a scroll-blocking event. Consider ma…

  1. I will immediately seize your rss feed as I can’t to find your e-mail subscription hyperlink or e-newsletter service.
    Do you have any? Kindly permit me know in order that I could subscribe.

  2. I know this web page gives quality based posts and additional material,
    is there any other site which presents these things in quality?

  3. Hello, i feel that i noticed you visited my web site so i got
    here to return the desire?.I’m trying to in finding issues to enhance my web site!I guess its ok to make use of a few of your ideas!!

  4. Howdy, I think your blog could be having browser compatibility issues.
    When I take a look at your web site in Safari, it looks fine however when opening in IE, it’s
    got some overlapping issues. I just wanted to provide you with
    a quick heads up! Besides that, wonderful blog!

  5. Magnificent goods from you, man. I have understand your stuff previous
    to and you’re just too great. I actually like what you
    have acquired here, certainly like what you’re
    stating and the way in which you say it. You make it entertaining and you still take care of to keep
    it wise. I can’t wait to read much more from you.
    This is really a terrific web site.


电子邮件地址不会被公开。 必填项已用*标注