vue3开发过程中,老是提示:
Added non-passive event listener to a scroll-blocking...
的提示,虽然不是error,但是看着也不舒服,截图如下:
解决办法:
1、在项目的config目录中新建ployfill.js文件
//去除谷歌浏览器的scroll、wheel等事件警告 (function () { if (typeof EventTarget !== "undefined") { let func = EventTarget.prototype.addEventListener; EventTarget.prototype.addEventListener = function (type, fn, capture) { this.func = func; if (typeof capture !== "boolean") { capture = capture || {}; capture.passive = false; } this.func(type, fn, capture); }; } }());
2、在main.js中引入此文件:
import "@/config/ployfill"
再刷新项目,不提示这个错误了!