当前位置:网站首页>Unable to preventDefault inside passive event listener due to target being treated as passive. See
Unable to preventDefault inside passive event listener due to target being treated as passive. See
2022-08-04 05:35:00 【&不羁之风&】
搭建项目出现问题记录
vux-ui官网:https://vux.li/
问题出现:
使用vux-ui框架时,经常在 chrome 的控制台看到如下提示:
Unable to preventDefault inside passive event listener due to target being treated as passive. See
问题原因:
Chorme56+开始为了让页面滚动变得更为流畅,在 window、document 和 body 上注册的 touchstart 和 touchmove 事件处理函数,会默认为是 passive: true。
浏览器忽略默认事件的preventDefault(), 你要是手动阻止会弹出一个警告, 告诉你阻止不了!!!
解决方案
在App.vue使用--大部分的解决方案都是以下两种:
window.addEventListener('touchmove', func, { passive: false })
* { touch-action:none; }
第一种方法passive在移动端滑动处理默认值为true,浏览器忽略preventDefault()
第二种方法touch-action是css中的一个属性,用于设置触摸屏用户如何操纵元素的区域(例如浏览器内置的缩放功能)
主要有以下这些值
/* Keyword values */
touch-action: auto;//当触控事件发生在元素上时,由浏览器来决定进行哪些操作,比如对viewport进行平滑、缩放等。
touch-action: none;//当触控事件发生在元素上时,不进行任何操作。
touch-action: pan-x;//启用单指水平平移手势。可以与 pan-y 、pan-up、pan-down 和/或 pinch-zoom 组合使用。
touch-action: pan-y;//启用单指垂直平移手势。可以与 pan-x 、pan-left 、pan-right 和/或 pinch-zoom 组合使用。
touch-action: pinch-zoom;//启用多手指平移和缩放页面。 这可以与任何平移值组合。
touch-action: manipulation;//浏览器只允许进行滚动和持续缩放操作。任何其它被auto值支持的行为不被支持。启用平移和缩小缩放手势,但禁用其他非标准手势,例如双击以进行缩放。 禁用双击可缩放功能可减少浏览器在用户点击屏幕时延迟生成点击事件的需要。 这是“pan-x pan-y pinch-zoom”(为了兼容性本身仍然有效)的别名。
touch-action:pan-left, pan-right,pan-up,pan-down;//启用以指定方向滚动开始的单指手势。 一旦滚动开始,方向可能仍然相反。 请注意,滚动“向上”(pan-up)意味着用户正在将其手指向下拖动到屏幕表面上,同样 pan-left 表示用户将其手指向右拖动。 多个方向可以组合,除非有更简单的表示(例如,“pan-left pan-right”无效,因为“pan-x”更简单,而“pan-left pan-down”有效)。
/* Global values */
touch-action: inherit;
touch-action: initial;
touch-action: unset;
边栏推荐
- MAML原理讲解和代码实现
- 0--100的能被3整出的数的集合打乱顺序
- Logical Address & Physical Address
- 无监督特征对齐的迁移学习理论框架
- Uos统信系统 Postfix-smtps & Dovecot-imaps
- ssm pom文件依赖 web.xml配置
- Pfsense漏洞复现(CVE-2021-41282)
- Visualization and Animation Technology (VR System)
- 自适应迁移学习核极限学习机用于预测
- Gramm Angle field GAF time-series data into the image and applied to the fault diagnosis
猜你喜欢
电脑知识:台式电脑应该选择品牌和组装,值得收藏
Gramm Angle field GAF time-series data into the image and applied to the fault diagnosis
狗都能看懂的变化检测网络Siam-NestedUNet讲解——解决工业检测的痛点
【C# - 爬虫】使用Selenium实现爬虫,获取近七天天气信息(包含完整代码)
Computer software: recommend a disk space analysis tool - WizTree
Online public account article content to audio file practical gadget
微软电脑管家2.0公测版体验
子空间结构保持的多层极限学习机自编码器(ML-SELM-AE)
数据库文档生成工具V1.0
电脑软件:推荐一款磁盘空间分析工具——WizTree
随机推荐
数据库JDBC DAO层方法
第九篇 ApplicationContext初始化
如何在Excel 里倒序排列表格数据 || csv表格倒序排列数据
对象的扩展补充
狗都能看懂的Pytorch MAML代码详解
Visualization and Animation Technology (3D Visualization)
网络安全学习的三大不可取之处
selenium webdriver 防爬问题 C#
ResNet详解:ResNet到底在解决什么问题?
CMDB 腾讯云部分实现
解决腾讯云DescribeInstances api查询20条记录以上的问题
QT QOpenGLWidget 全屏导致其他控件显示问题
Operating System Kernel
Interpretation of EfficientNet: Composite scaling method of neural network (based on tf-Kersa reproduction code)
Database knowledge: SQLServer creates non-sa user notes
YOLOv3详解:从零开始搭建YOLOv3网络
注册表设置默认浏览器 win7,winserver 2008,winserver 2012
把DocumentsandSettings迁移到别的盘
av_read_frame 阻塞,基于回调的解决办法
golang 的库引用方法