首页 > 移动平台 > 详细

iOS唤起input慢

时间:2019-11-22 16:47:34      阅读:108      评论:0      收藏:0      [点我收藏+]
在JS中添加如下代码即可:
FastClick.attach(document.body); //300ms延迟
//init
/**
  * @param {EventTarget|Element} targetElement
  */
FastClick.prototype.focus = function (targetElement) {
    var length;

    // Issue #160: on iOS 7, some input elements (e.g. date datetime month) throw a vague TypeError on setSelectionRange. These elements don‘t have an integer value for the selectionStart and selectionEnd properties, but unfortunately that can‘t be used for detection because accessing the properties also throws a TypeError. Just check the type instead. Filed as Apple bug #15122724.
    if (deviceIsIOS && targetElement.setSelectionRange && targetElement.type.indexOf(‘date‘) !== 0 && targetElement.type !== ‘time‘ && targetElement.type !== ‘month‘ && targetElement.type !== ‘email‘) {
        length = targetElement.value.length;
        targetElement.focus();//加入这一句话就OK了
        targetElement.setSelectionRange(length, length);
    } else {
        targetElement.focus();
    }
};

 

iOS唤起input慢

原文:https://www.cnblogs.com/zhangxin123/p/11912257.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!