问题

当使用fastClick.js设置点击事件时,控制台报错:

[Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive. See https://www.chromestatus.com/features/5093566007214080

意思是 无法被动监听事件中的默认事件.

preventDefault就是阻止事件的默认事件,如果设置了preventDefault,则form表单不会提交,a链接不会跳转

原因产生

AddEventListenerOptions defaults passive to false. With this change touchstart and touchmove listeners added to the document will default to passive:true (so that calls to preventDefault will be ignored)..

If the value is explicitly provided in the AddEventListenerOptions it will continue having the value specified by the page.

This is behind a flag starting in Chrome 54, and enabled by default in Chrome 56. See https://developers.google.com/web/updates/2017/01/scrolling-intervention

AddEventListenerOptions默认为被动为false。通过此更改,添加到文档中的touchstart和touchmove侦听器将默认为passive:true(以便忽略对preventDefault的调用)。。

如果AddEventListenerOptions中显式提供了该值,则它将继续具有页面指定的值。

这在Chrome 54开始的标志后面,在Chrome 56中默认启用。参见https://developers.google.com/web/updates/2017/01/scrolling-intervention

解决方案

  1. 添加监听事件选项{passive: false}

    window.addEventListener('touch事件',[callback],{passive: false});
  2. 使用css属性

    touch-action: none; 这样任何触摸事件都不会产生默认行为,而且touch事件还会触发

设置点击事件时Unable to preventDefault inside passive event listener due to target being treated as passive的更多相关文章

  1. 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 今天在做项目 ...

  2. 移动端页面滑动时候警告:Unable to preventDefault inside passive event listener due to target being treated as passive.

    移动端项目中,在滚动的时候,会报出以下提示: [Intervention] Unable to preventDefault inside passive event listener due to ...

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

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

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

    最近两天企业微信下IScroll突然无法滚动了,特别慢,之前好好的,发现主要是有红色的Unable to preventDefault inside passive event listener du ...

  5. [Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive. See https://www.chromestatus.com/features/5093566007214080

    相信如果用谷歌浏览器做移动端页面的时候 用touch事件的时候应该遇到过这个东东吧 documet.addEventListener("touchstart",function() ...

  6. Unable to preventDefault inside passive event listener due to target being treated as passive 怎么办?

    本篇为转载,原文链接:https://blog.csdn.net/lijingshan34/article/details/88350456 翻译一下:chrome 监听touch类事件报错:无法被动 ...

  7. 关于Google浏览器Unable to preventDefault inside passive event listener due to target being treated as passive.的解决方案

    最近写react项目的时候,引用了antd-mobile,在使用滚动组件的时候,发现谷歌浏览器会报以下警告 最初我以为是antd-mobile的问题导致的,然后我就无查看了之前的vue的项目,发现了类 ...

  8. Unable to preventDefault inside passive event listener due to target being treated as passive. See https://www.chromestatus.com/features/5093566007214080

    解决办法: 两个方案:1.注册处理函数时,用如下方式,明确声明为不是被动的window.addEventListener('touchmove', func, { passive: false }) ...

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

    使用滚动时候,新版google浏览器,会弹出如下的警告. 解决方法,可以加上* { touch-action: none; } 这句样式去掉. 其原因:https://developers.googl ...

  10. Vue移动端报错[Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive.

    解决方法如下 项目方案: 在最外侧添加样式操作 .

随机推荐

  1. CTFshow——funnyrsa2

    题目如下: 题目分析: 发现n很小,可以考虑yafu分解n,或者使用在线网站,例如:http://factordb.com/.即得p,q,r.因为常规rsa只有p和q,则phi = (p -1) * ...

  2. C语言函数值传递问题

    C语言函数间值传递问题 错误示例 #include <stdio.h> int * pop() { int a[3]; // 定义的局部变量a[3]在调用完之后自动释放其空间 int i ...

  3. ffmpeg第8篇:使用ffprobe采集文件信息

    1. 前言 ffprobe是ffmpeg的其中一个模块,主要用于查看文件信息,咱们知道一个MP4文件其实不仅仅包含了音视频数据,还有如元数据等其它信息,但是实际上咱们关心的往往是音视频数据部分,今天来 ...

  4. [cocos2d-x]TextureCache和spriteFramecache

    SpriteFrameCache 主要服务于多张碎图合并出来的纹理图片.这种纹理在一张大图中包含了多张小图,直接通过TextureCache引用会有诸多不便,因而衍生出来精灵框帧的处理方式,即把截取好 ...

  5. Sundial (二)

    相关重要的组件一览 Triggers(触发器)相关类 保存触发器相关参数,例如起止时间,次数,间隔时间等,其中Sundial支持多种类型触发器 多种类型的触发器必须重写GetNextOccurrenc ...

  6. sun.security.validator.ValidatorException: PKIXpath building failed: sun.security.provider,javax.net.ssT.SSLHandshakeExceptions.certpath.SunCertPathBuilderException

    报错信息: sun.security.validator.ValidatorException: PKIXpath building failed: sun.security.provider,jav ...

  7. 了解 Transformers 是如何“思考”的

    Transformer 模型是 AI 系统的基础.已经有了数不清的关于 "Transformer 如何工作" 的核心结构图表. 但是这些图表没有提供任何直观的计算该模型的框架表示. ...

  8. 连接KingbaseES异常,致命错误/ 用户"system" Password 认证失败(kbjdbc/autodetected server-encoding to be GB2312...)

    com.kingbase8.util.KSQLException: 致命错误: 用户"system" Password 认证失败(kbjdbc:autodetected serve ...

  9. Python装饰器实例讲解(二)

    Python装饰器实例讲解(二) Python装饰器实例讲解(一) 你最好去看下第一篇,虽然也不是紧密的链接在一起 参考B站码农高天的视频,大家喜欢看视频可以跳转忽略本文:https://www.bi ...

  10. 重启系统(等级考试4级 2021-03 T4)

    这道题如果没有一次重启系统的机会就相当于两个最长不下降子序列加在一起. 所以只需要改亿点点即可 把dp分为 dpleft 和 dpright 最长不下降子序列程序:最长上升子序列 II 时间复杂度(n ...