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.

翻译过来如下:
违反:没有添加被动事件监听器来阻止’touchstart’事件,请考虑添加事件管理者’passive’,以使页面更加流畅。
原因是 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’

参考:https://blog.csdn.net/dj0379/article/details/52883315

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.
    Thanks.

  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.

发表评论

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