Fork me on GitHub

解决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

posted @ 2020-08-28 15:57  思考的大腿  阅读(595)  评论(0编辑  收藏  举报