[Intervention] Unable to preventDefault inside passive event listener due to target being treated as

Posted crazycode2

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[Intervention] Unable to preventDefault inside passive event listener due to target being treated as相关的知识,希望对你有一定的参考价值。

1.滑动时候警告[Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive.

技术分享图片

2.解决方案

解决办法1:

在touch的事件监听方法上绑定第三个参数{ passive: false },
通过传递 passive 为 false 来明确告诉浏览器:事件处理程序调用 preventDefault 来阻止默认滑动行为。

elem.addEventListener(
  ‘touchstart‘,
  fn,
  { passive: false }
);

解决办法2:

 * { touch-action: pan-y; } 
 // 使用全局样式样式去掉

.

 


以上是关于[Intervention] Unable to preventDefault inside passive event listener due to target being treated as的主要内容,如果未能解决你的问题,请参考以下文章

滑动时报错[Intervention] Unable to preventDefault inside passive event listener due to target being treat

[Intervention] Unable to preventDefault inside passive event listener due to target being treated as

Web前端笔记-解决[Intervention] Unable to preventDefault inside passive event listener due to target being

mui执行滑动事件: Unable to preventDefault inside passive event listener

Unable to preventDefault inside passive event listener due to target being treated as passive.

Unable to preventDefault inside passive event listener due to target being treated as passive?