移动端项目中,在滚动的时候,会报出以下提示:

[Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive.
See https://www.chromestatus.com/features/5093566007214080

解决

  1. 在touch的事件监听方法上绑定第三个参数{ passive: false },

    通过传递 passive 为 false 来明确告诉浏览器:事件处理程序调用 preventDefault 来阻止默认滑动行为。
target.addEventListener('touch', function () {

}, { passive: false });
  1. 在 CSS 中全局使用:
* {
touch-action: pan-y;
}

touch-action 的使用方法见:https://developer.mozilla.org/zh-CN/docs/Web/CSS/touch-action

参考:

https://juejin.im/post/5ad804c1f265da504547fe68

https://www.jianshu.com/p/04bf173826aa

移动端页面滑动时候警告: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 treated as passive.

    1.滑动时候警告[Intervention] Unable to preventDefault inside passive event listener due to target being tr ...

  2. 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 今天在做项目 ...

  3. IScroll Unable to preventDefault inside passive event listener due to target being treated as passive

    最近两天企业微信下IScroll突然无法滚动了,特别慢,之前好好的,发现主要是有红色的Unable to preventDefault inside passive event listener du ...

  4. [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() ...

  5. 滑动报 Unable to preventDefault inside passive event listener due to target being treated as passive 的解决方法

    google浏览器滑动出现以下问题: 解决办法如下:在html元素下添加样式 touch-action: none; html{ touch-action:none; }

  6. Vue移动端报错[Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive.

    解决方法如下 项目方案: 在最外侧添加样式操作 .

  7. Unable to preventDefault inside passive event listener due to target being treated as passive?

    使用滚动时候,新版google浏览器,会弹出如下的警告. 解决方法,可以加上* { touch-action: none; } 这句样式去掉. 其原因:https://developers.googl ...

  8. 关于Google浏览器Unable to preventDefault inside passive event listener due to target being treated as passive.的解决方案

    最近写react项目的时候,引用了antd-mobile,在使用滚动组件的时候,发现谷歌浏览器会报以下警告 最初我以为是antd-mobile的问题导致的,然后我就无查看了之前的vue的项目,发现了类 ...

  9. Unable to preventDefault inside passive event listener due to target being treated as passive 怎么办?

    本篇为转载,原文链接:https://blog.csdn.net/lijingshan34/article/details/88350456 翻译一下:chrome 监听touch类事件报错:无法被动 ...

随机推荐

  1. 03-02_配置weblogic domain

    配置Domain 图形化界面: [Windows] Windows菜单 [windows] config.cmd [Unix/Linux] config.sh 命令行界面: [windows] con ...

  2. maven+spring+junit测试要注意的事情

    使用maven方式创建webapp工程的资料网上一大堆,在这里也不详细说了.在创建完成之后,里面说到要转动态web工程时要切换为3.0版本,但是我本地切换不了,网上的方法好像也没用,暂时也没用到这块. ...

  3. Spring中的destroy-method方法

    1. Bean标签的destroy-method方法 配置数据源的时候,会有一个destroy-method方法 <bean id = "dataSource" class  ...

  4. 微信小程序里使用过滤器

    新建一个 filter.wxs文件 function formatString(val, len) { if (val.length > len) { return val.substring( ...

  5. 【排序算法】冒泡排序(Bubble Sort)

    0. 说明 参考 维基百科中的冒泡排序 冒泡排序 (Bubble Sort) 是与插入排序拥有相等的执行时间,但是两种算法在需要的交换次数却很大地不同. 在最坏的情况,冒泡排序需要 O(n2)  次交 ...

  6. 在 Virtual Box 中为 CentOS7 mini 配置双网卡

    1. 配置过程 1.1 需求分析 要同时满足虚拟机访问互联网和远程连接,需要配置两块网卡. 一块为 NAT 网络,这块用来访问互联网. 另一块为 Host-Only 网络,进行远程连接.   1.2 ...

  7. 【转】Java十大常用框架介绍(spring系+dubbo+RabbitMQ+Ehcache+redis)

    一.SpringMVC Spring Web MVC是一种基于Java的实现了Web MVC设计模式的请求驱动类型的轻量级Web框架,即使用了MVC架构模式的思想,将web层进行职责解耦,基于请求驱动 ...

  8. XtraEditors六、ListBoxControl、CheckedListBoxControl、ImageListBoxControl

    ListBoxControl 效果如下: 示例代码: string[] girlArr = { "面码", "Saber", "Mathilda&qu ...

  9. Symbol Table Applications

    符号表应用 在计算机发展的早期,符号表帮助程序员从使用机器语言的数字地址进化到在汇编语言中使用符号名称:在现代应用程序中,符号名称的含义能够通行于跨域全球的计算机网络.快速查找算法曾经并继续在计算机领 ...

  10. win10系统上Python和pycharm的安装及配置

    1.https://www.python.org/downloads/windows/进入官网下载需要的Python安装包(以2.7版本为例) 2.http://www.jetbrains.com/p ...