zoukankan      html  css  js  c++  java
  • 苹果系统click点击事件的300ms延迟问题

    安装fastclick

    npm install fastclick --save-dev

    在main.js中引入

    import FastClick from 'fastclick'

    在mouted中添加 

    FastClick.attach(document.body)

    在引入fastclick之后,虽然页面事件快了很多,但是会有一个副作用:input输入框需要连续点击两次或者长按才能获取焦点,

    解决方案:在main.js添加如下代码

    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') {
      length = targetElement.value.length;
      targetElement.focus();
      targetElement.setSelectionRange(length, length);
     } else {
      targetElement.focus();
    }
    };
    集思广益,仅供学习,侵权即删!!
  • 相关阅读:
    ArrayList 和 LinkList 的区别
    fork()相关的源码解析
    http协议状态码及其意义
    数据库的死锁相关知识
    JDBC事务的相关知识
    请求http页面的相关过程
    static 关键字的作用
    计算机网络网络层的IP地址划分及子码
    文件的相关操作.
    set集合和深浅拷贝
  • 原文地址:https://www.cnblogs.com/hudunyu/p/13070075.html
Copyright © 2011-2022 走看看