首先为什么存在延迟?

根据 Google 开发者文档:

...mobile browsers will wait approximately 300ms from the time that you tap the button to fire the click event. The reason for this is that the browser is waiting to see if you are actually performing a double tap.

译:
从点击屏幕上的元素到触发元素的 click 事件,移动浏览器会有大约 300 毫秒的等待时间。为什么这么设计呢? 因为它想看看你是不是要进行双击(double tap)操作。

FastClick是什么?

由 FTLabs 开发,Github 项目地址:https://github.com/ftlabs/fastclick
专门用来处理移动端点击事件的300毫秒延迟,

如何使用FastClick

首先引用js

<script type='application/javascript' src='/path/to/fastclick.js'></script>

然后在body内加入:

if ('addEventListener' in document) {
    document.addEventListener('DOMContentLoaded', function() {
        FastClick.attach(document.body);
    }, false);
}

或者,如果您正在使用jQuery:

$(function() {
    FastClick.attach(document.body);
});

详细食用方法请看原作者的github吧https://github.com/ftlabs/fastclick

版权属于:泽泽社长
本文链接:https://blog.zezeshe.com/archives/FastClick.html
本站未注明转载的文章均为原创,并采用 CC BY-NC-SA 4.0 授权协议,转载请注明来源,谢谢!