设置点击事件时Unable to preventDefault inside passive event listener due to target being treated as passive
问题
当使用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
解决方案
- 添加监听事件选项{passive: false}
window.addEventListener('touch事件',[callback],{passive: false}); - 使用css属性
touch-action: none; 这样任何触摸事件都不会产生默认行为,而且touch事件还会触发
设置点击事件时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
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.
移动端项目中,在滚动的时候,会报出以下提示: [Intervention] Unable to preventDefault inside passive event listener due to ...
- [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 ...
- IScroll Unable to preventDefault inside passive event listener due to target being treated as passive
最近两天企业微信下IScroll突然无法滚动了,特别慢,之前好好的,发现主要是有红色的Unable to preventDefault inside passive event listener du ...
- [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() ...
- Unable to preventDefault inside passive event listener due to target being treated as passive 怎么办?
本篇为转载,原文链接:https://blog.csdn.net/lijingshan34/article/details/88350456 翻译一下:chrome 监听touch类事件报错:无法被动 ...
- 关于Google浏览器Unable to preventDefault inside passive event listener due to target being treated as passive.的解决方案
最近写react项目的时候,引用了antd-mobile,在使用滚动组件的时候,发现谷歌浏览器会报以下警告 最初我以为是antd-mobile的问题导致的,然后我就无查看了之前的vue的项目,发现了类 ...
- 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 }) ...
- Unable to preventDefault inside passive event listener due to target being treated as passive?
使用滚动时候,新版google浏览器,会弹出如下的警告. 解决方法,可以加上* { touch-action: none; } 这句样式去掉. 其原因:https://developers.googl ...
- Vue移动端报错[Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive.
解决方法如下 项目方案: 在最外侧添加样式操作 .
随机推荐
- Java基础类String学习分析
目录 1 String不可变性 2 不可变的好处 3 String+和StringBuilder效率差异 4 String, StringBuffer and StringBuilder 5 Stri ...
- 数据库日志——binlog、redo log、undo log扫盲
日志是数据库中比较重要的组成部分,很多核心的功能必须依靠日志才能完成. 该篇文章简要介绍了binlog.redo log与undo log,能够在一定程度上拓宽对mysql日志的整体认识. binlo ...
- Hive详解(05) - 压缩和存储
Hive详解(05) - 压缩和存储 Hadoop压缩配置 MR支持的压缩编码 压缩格式 算法 文件扩展名 是否可切分 DEFLATE DEFLATE .deflate 否 Gzip DEFLATE ...
- 解决node.js报错Invalid character in header content ["Content-Disposition"]
遇到这种报错一般在于下载文件时候,如果Content-Disposition设置文件名有中文会出现此种问题,解决方案如下: 把第二段代码改为第一段,即可~~ 'Content-Disposition' ...
- django框架之drf:04、序列化器常用字段及参数,序列化器高级用法之source、定制字段数据的两种方法、多表关联反序列化的保存、ModelSerializer的使用
Django框架之drf 目录 Django框架之drf 一.序列化器常用字段及参数 1.常用字段 2.常用字段参数 3.字段参数针对性分类 二.序列化器高级用法之source 1.定制字段名 三.定 ...
- SAOI 题解汇总
题解汇总 A. Chery 的魔法药水与 lrc 的韭菜 所有部分分代码及标程均在这里. 这个题目是我们前面的月考卷子改编后的 idea,去年就出了,今年翻出来经过加强得到了这道入门 题目. 首先,不 ...
- springboot自定义验证-传值范围
package com.xf.common; import static java.lang.annotation.ElementType.ANNOTATION_TYPE; import static ...
- redis实现分布式锁(包含代码以及分析利弊)
redis实现分布式锁(基础版) 使用redis实现分布式锁的方法有多种,基础版本是基于setnx命令,即如果不存在则设置.这个命令可以保证只有一个客户端能够成功设置一个key,从而获得锁.设置key ...
- 从实现到原理,聊聊Java中的SPI动态扩展
原创:微信公众号 码农参上,欢迎分享,转载请保留出处. 八股文背多了,相信大家都听说过一个词,SPI扩展. 有的面试官就很喜欢问这个问题,SpringBoot的自动装配是如何实现的? 基本上,你一说是 ...
- C# File、FileInfo、Directory、DirectoryInfo
本文主要介绍文件类.文件信息类.目录类.目录信息类的常用属性和方法 1.File(文件类) // 1.判断文件是否存在 bool isFileExist = File.Exists(@"D: ...