← 返回完整题库
JavaScript中等

移动端为什么会有 300ms 点击延迟,如何解决?

参考答案

原因

早期移动浏览器为区分"单击"与"双击缩放",在 touchend 后等待约 300ms 判断是否有第二次点击,导致 click 延迟。

解决

  1. <meta name="viewport" content="width=device-width, initial-scale=1">:现代浏览器在该配置下已取消延迟;
  2. CSS:touch-action: manipulation(禁止双击缩放,去掉延迟);
  3. 用 touchend 自行处理点击(注意 preventDefault 会阻断滚动/长按);
  4. FastClick 库(历史方案,绑定 touchend 后立即派发 click);
  5. 使用 Pointer Events。

现代项目基本只需 viewport 配置 + touch-action,无需 FastClick。

本题来自 计算机知识面试题库,共 921 道题。