问题

当使用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事件还会触发

最新文章

  1. DrawerLayout 和 NavigationView 的使用
  2. GROUP_CONCAT将里面拼接的字符串排序
  3. HAProxy的日志配置以及ACL规则实现负载均衡
  4. 存储过程里面使用in变量列表异常的处理
  5. cuda-convnet windows8下编译
  6. ios上架
  7. 关于bootstrap--表单(下拉<select>、输入框<input>、文本域<textare>复选框<checkbox>和单选按钮<radio>)
  8. Spyder提示ValueError: API 'QString' has already been set to version 1
  9. JS计算字符串长度(中文算2个)
  10. 项目管理实践教程一、工欲善其事,必先利其器【Basic Tools】
  11. ajax同步与异步的坑
  12. 吐血bug-- 多个input框接连blur事件导致alert接连弹出
  13. sprinbcloud学习之-Failed to bind properties under 'logging.level' to java.util.Map<java.lang.String>
  14. nodejs + typescirpt + vs code
  15. sql多条件查询语句
  16. HDU3031 To Be Or Not To Be 左偏树 可并堆
  17. 不输入密码执行sudo 命令
  18. tkinter events format
  19. 查看修改MySQL字符集
  20. 在LaTeX中配置西夏文字体与环境

热门文章

  1. java8新特性学习笔记
  2. python进阶之路9文件的处理方法
  3. Java运算的精度和溢出问题
  4. Java学习笔记:2022年1月8日
  5. 普冉PY32系列(二) Ubuntu GCC Toolchain和VSCode开发环境
  6. Gvim基础操作-01
  7. 保姆级手把手图文并茂教你配置MAC系统Flutter环境
  8. 解决前端发送post 请求出现403,cancled等问题
  9. 方法的调用-JDK的JShell简单使用
  10. SQLSERVER 快照隔离级别 到底怎么理解?