滑动时候警告:Unable to preventDefault inside passive event listener

admin 2019-08-30 12:32:57 0 0 Vue.js 254 复制链接

解决办法1:

在touch的事件监听方法上绑定第三个参数{ passive: false },
通过传递 passive 为 false 来明确告诉浏览器:事件处理程序调用 preventDefault 来阻止默认滑动行为。

elem.addEventListener(
  'touchstart',
  fn,
  { passive: false }
);

解决办法2:

 * { touch-action: pan-y; } 
 使用全局样式样式去掉

Passive event listeners

2016年Google I/O上提出的概念,目的是用来提升页面滑动的流畅度。

For instance, in Chrome for Android 80% of the touch events that block scrolling never actually prevent it. 10% of these events add more than 100ms of delay to the start of scrolling, and a catastrophic delay of at least 500ms occurs in 1% of scrolls.


评论(0)

    还没有评论,快来抢沙发吧!