解决FastClick ios input 输入框获取焦点慢的问题

ios webview 中,input 获取焦点 “点”的操作不要用,要用指肚去 “按” 才能获取焦点,去Github issues里找到如下解决方法:

FastClick.prototype.focus = function (targetElement) { //解决FastClick在ios输入框聚焦慢
let length;
if (targetElement.setSelectionRange && targetElement.type.indexOf('date') !== 0 && targetElement.type !== 'time' && targetElement.type !== 'month') {
length = targetElement.value.length;
targetElement.focus();
targetElement.setSelectionRange(length, length);
} else {
targetElement.focus();
}
}
FastClick.attach(document.body)

参考资料:https://github.com/ftlabs/fastclick/issues?q=ios+input

原文地址:https://www.cnblogs.com/thinkingthigh/p/13578013.html