滑动时候警告:Unable to preventDefault inside passive event listener
1 前言
在制作2048时,需要在手机端添加滑动检测事件,然后发现控制台有警告,如下:
main2048.js:218 [Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive. See https://www.chromestatus.com/features/5093566007214080
2 解决办法:
在touch的事件监听方法上绑定第三个参数{ passive: false },
通过传递 passive 为 false 来明确告诉浏览器:事件处理程序调用 preventDefault 来阻止默认滑动行为。
方法1
elem.addEventListener(
'touchstart',
fn,
{ passive: false }
);
方法2
* { touch-action: pan-y; }
使用全局样式样式去掉
3 参考
1. 滑动时候警告:Unable to preventDefault inside passive event listener
滑动时候警告:Unable to preventDefault inside passive event listener的更多相关文章
- 移动端页面滑动时候警告:Unable to preventDefault inside passive event listener due to target being treated as passive.
移动端项目中,在滚动的时候,会报出以下提示: [Intervention] Unable to preventDefault inside passive event listener due to ...
- 引用fastclick.js或使用触屏监听 滑动屏幕报错:解决[Intervention] Unable to preventDefault inside passive event listener
使用fastClick.js所产生的一些问题 开发h5活动页时想到移动端会有300ms的延迟,于是便打算用fastClick.js解决. 页面引入fastClick.js后,滑动H5页面的时候发现谷歌 ...
- [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 ...
- 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
最近做项目经常在 chrome 的控制台看到如下提示: Unable to preventDefault inside passive event listener due to target bei ...
- IScroll Unable to preventDefault inside passive event listener due to target being treated as passive
最近两天企业微信下IScroll突然无法滚动了,特别慢,之前好好的,发现主要是有红色的Unable to preventDefault inside passive event listener du ...
- 滑动时候报错:Unable to preventDefault inside passive event listener, 移动端滑动性能优化
https://www.jianshu.com/p/04bf173826aa 记录下 这篇帖子 解决办法1: 在touch的事件监听方法上绑定第三个参数{ passive: false }, 通过传 ...
- [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 的解决方法
google浏览器滑动出现以下问题: 解决办法如下:在html元素下添加样式 touch-action: none; html{ touch-action:none; }
随机推荐
- python中print和input的底层实现
print print的底层通过sys.stdout.write() 实现 import sys print('hello') print('world') print(520) sys.stdout ...
- eclipse竖向选择快捷键
eclipse的编辑器自带竖向选择功能,在mac上的开启和关闭方法都是command+option+a,在windows下则为alt+shift+a
- udp_connect函数
#include <netdb.h> #include <stdlib.h> #include <unistd.h> #include <string.h&g ...
- 在SQL注入中利用MySQL隐形的类型转换绕过WAF检测
web应用一般采用基于表单的身份验证方式(页面雏形如下图所示),处理逻辑就是将表单中提交的用户名和密码传递到后台数据库去查询,并根据查询结果判断是否通过身份验证.对于LAMP架构的web应用而言,处理 ...
- Intelij IDEA 内置 sql gui
IDEA 内置 自带 SQL GUI 最大意义 会自动识别 domain 对象与数据表的关系,也可以通过 Database 的数据表直接生成 domain 对象等等. 第一步 打开数据库视图 Vie ...
- Debian Security Advisory(Debian安全报告) DSA-4416-1 wireshark security update
Debian Security Advisory(Debian安全报告) DSA-4416-1 wireshark security update Package:wireshark CVE ID : ...
- day 10 - 1 函数进阶
函数进阶 命名空间和作用域 命名空间 命名空间 有三种内置命名空间 —— python解释器 就是python解释器一启动就可以使用的名字存储在内置命名空间中 内置的名字在启动解释器的时候被加载进内存 ...
- 网易云课堂《JS原创视频教程-知识点类》
http://caniuse.com/#index //Can I use... Support tables for HTML5, CSS3, etc-支持h5和css3的情况列表 JS包含 ...
- Tip:HttpServletRequest
HttpServletRequest对象代表客户端的请求,当客户端通过HTTP协议访问服务器时,HTTP请求头中的所有信息都封装在这个对象中,开发人员通过这个对象的方法,可以获得客户这些信息. Tip ...
- Java学习过程中要记录的地方--汇总
1.Map的子类 HashMap 是哈希表,根据哈希算法来存的,取出来不一定是按照原来的循序: Ctrl+T 可以看到 HashMap下面有 LinkHashMap 是线性实现的,里面有顺序. --- ...