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();
    }
    };
    集思广益,仅供学习,侵权即删!!
  • 相关阅读:
    洛谷P2444 病毒【AC自动机】
    AC自动机
    洛谷试炼场2-5---字符串处理【字符串】
    洛谷试炼场1-5---简单字符串【字符串】
    poj2185 Milking Grid【KMP】
    poj3630 Phone List【Trie树】
    CH1809匹配统计【KMP】
    打包命令
    django_auth模块
    mongodb-Configuration
  • 原文地址:https://www.cnblogs.com/hudunyu/p/13070075.html
Copyright © 2011-2022 走看看