原因
错误原因
-
Passive Event Listeners:
-
现代浏览器为了提高滚动性能,默认将某些事件(如
touchstart
、touchmove
、wheel
等)标记为 passive。 -
如果事件监听器中调用了
event.preventDefault()
,但事件被标记为passive
,浏览器会抛出这个警告。
-
-
Element Plus 的日期组件:
-
Element Plus 的日期组件可能在某些交互(如点击日期)中触发了
touch
或wheel
事件,而事件监听器中可能包含preventDefault()
。
-
看网上好多办法尝试了一下都没啥用。
最后在main.js里面加上这段代码解决了
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); }; }