问题

当使用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. 百度智能云 API调用PythonSDK

    百度智能云 API调用PythonSDK 这是一个用于百度云部分开放AI功能的Python库.主要为ORC功能,可以对各种图像文件进行文字识别,包括车牌.手写文字.通用文字.人脸发现.人脸比对和人流量 ...

  2. Kali Pi 安装 RTL8812AU驱动

    今天,我们来实操安装一下昨天的RTL8812​的无线网卡驱动. 说明 我们今天使用的网卡是磊科的NW392无线网卡,其主要核心为NW392. 一张32G内存卡 树莓派为树莓派4B 4G-RAM 系统为 ...

  3. 一文了解华为FusionInsight MRS HBase的集群隔离方案RSGroup

    摘要: RSGroup是集群隔离方案. 本文分享自华为云社区<华为FusionInsight MRS HBase的集群隔离--RSGroup>,作者: MissAverage. 一.HBa ...

  4. python之路24之 面向对象动静态方法、继承、派生

    昨日内容回顾 人狗大战 1.直接使用字典表示人和狗 p1 = {} p2 = {} p3 = {} p4 = {} 2.封装产生人和狗的函数 def crreate_person():pass def ...

  5. elasticsearch实现基于拼音搜索

    目录 1.背景 2.安装拼音分词器 3.拼音分词器提供的功能 4.简单测试一下拼音分词器 4.1 dsl 4.2 运行结果 5.es中分词器的组成 6.自定义一个分词器实现拼音和中文的搜索 1.创建m ...

  6. 腾讯出品小程序自动化测试框架【Minium】系列(三)元素定位详解

    写在前面 昨天转发这篇文章时,看到群里有朋友这样说: 这么卷吗?这个框架官方已经不维护了. 姑且不说卷不卷的问题,要是能卷明白,别说还真不错: 不维护又怎样?我想学习,想会,分享给很期待这系列的文章的 ...

  7. 洛谷 P1208混合牛奶 题解

    一道贪心算法不是很明显的题目,其实一般的递推也可以做. 大体思路:肯定优先购买单价最低的奶农的牛奶,那么就需要先根据牛奶单价进行排序,这里用结构体会更好一点.之后在从前往后一个一个枚举,直至购买的牛奶 ...

  8. Linux操作系统导学专栏(一)——专栏要讲些什么?

    ​ 该专栏是为Linux内核开发编程做铺垫,如果你对操作系统很熟悉,想了解一些Linux内核发开的知识,请直接跳转至<Linux内核编程专栏>,如果你对Linux内核编程也很熟悉,想了解L ...

  9. 使用prometheus来避免Kubernetes CPU Limits造成的事故

    使用prometheus来避免Kubernetes CPU Limits造成的事故 译自:Using Prometheus to Avoid Disasters with Kubernetes CPU ...

  10. 关于我在学习LFU的时候,在开源项目捡了个漏这件事。

    你好呀,我是歪歪. 这篇文章带大家盘一下 LFU 这个玩意. 为什么突然想起聊聊这个东西呢,因为前段时间有个读者给我扔过来一个链接: 我一看,好家伙,这不是我亲爱的老朋友,Dubbo 同学嘛. 点进去 ...