设置点击事件时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.
解决方法如下 项目方案: 在最外侧添加样式操作 .
随机推荐
- git remote update origin --prune命令失败
1.问题描述 我使用git remote update origin --prune命令更新远程分支上的代码,结果出现如下报错. 2.产生原因 本地关联的远程仓库失效了,需要重新再关联一下. 3.解决 ...
- [OpenCV实战]39 在OpenCV中使用ArUco标记的增强现实
文章目录 1 什么是ArUco标记? 2 在OpenCV中生成ArUco标记 3 检测Aruco标记 4 增强现实应用 5 总结和代码 5.1 生成aruco标记 5.2 使用aruco增强现实 6 ...
- Java求值策略
为什么说Java不存在引用传递? 在Java语言中,存在两种数据类型,一种是基本类型,如int.byte等8种基本类型,一种是引用类型,如String.Integer等.这两种数据类型区别就在于,基本 ...
- 数据分析中的SQL如何解决业务问题
本文来自知乎问答. 提问:数据分析人员需要掌握sql到什么程度? 请问做一名数据分析人员,在sql方面需要掌握到什么程度呢?会增删改查就可以了吗?还是说关于开发的内容也要会?不同阶段会有不同的要求吗? ...
- shell端口监听异常邮箱告警
业务场景:应用发布监听服务是否正常启动,因为服务器资源不够上不了prometheus.grafana,所以写的shell脚本监听.此脚本适用于初创公司及小微企业使用. 准备工作 除了shell脚本这里 ...
- A. Greatest Convex【Codeforces Round #842 (Div. 2)】
A. Greatest Convex You are given an integer \(k\). Find the largest integer \(x\), where \(1≤x<k\ ...
- 为什么要虚拟化,为什么要容器,为什么要Docker,为什么要K8S?
前言 如标题中的问题所提到的虚拟化,容器,Docker和K8s那样,我们不妨这样问:这些技术到底适用于哪些场景,有没有别的技术可以替代?这些技术的优劣在哪里? 下面我将针对性地从以上几个问题的出发点, ...
- dfs 返回值用bool相对void会快一点
力扣 剑指 Offer 12. 矩阵中的路径 超时代码 dfs返回值是void,用类内的全局变量flag表示找到或没找到. class Solution { public: bool flag; in ...
- 解决angular11+zorro使用table组件排序失效以及分页组件失效问题,附完整DEMO代码
关于这个排序失效问题的核心点,跟这个有关系:[nzFrontPagination]="false" 关于分页组件失效的问题,是你获取数据以后,需要给页码,页数,总条数都要重新赋值, ...
- 炫酷科技感黑客感瀑布流html代码
效果如下 代码如下 <!DOCTYPE html><html> <head> <meta http-equiv="Content-Type" ...