感谢@ tony19,为输入。
我们想避免延误,所以我研究了一些并最终解决了问题。回答我自己的问题:最终的解决方案确实存在于FastClick库中。
基本上发生的事情是,tap
事件立即被触发,但它不会替代click事件。相反,点击事件仍会触发,但延迟时间为原来的300毫秒。这个延迟点击事件因此在新显示的“页面”上触发,并在相同的x-y坐标处触发输入字段(或按钮在那里)。
添加FastClick库再次解决了这个问题,这要归功于库中的一些更新。但是,它会打破一些需要原始点击的项目,例如Google自动填充。一个基本的解决方案,以排除FastClick是改为采用它作为:
FastClick.attach(document.body, {
excludeNode: 'something', });
然而,这仅适用于该节点和不可能的孩子。因此,要解决一切与谷歌的自动完成输入字段,以及利用做:
// Disable FastClick for the children of a google auto-
// complete component.
var needsClick = FastClick.prototype.needsClick;
FastClick.prototype.needsClick = function(target) {
if ((target.className || '').indexOf('pac-item') > -1) {
return true;
} else if ((target.parentNode.className || '').indexOf('pac-item') > -1) {
return true;
} else {
return needsClick.apply(this, arguments);
}
};
// Remove click delay on iOS. As such, removing differences
// in timing between click and tap, thereby avoiding the
// fall-through problem.
FastClick.attach(document.body);
我现在将关闭这个线程,但我认为它会是不错的离开这个作为参考其他任何人经历问题。