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();
    }
    };
    集思广益,仅供学习,侵权即删!!
  • 相关阅读:
    poj1243(经典dp)
    hdu3485(递推)
    poj2479(dp)
    hdu3415(单调队列)
    hdu1876(dp)
    hdu1042(大数模板)
    hdu2125(数学)
    hdu1992(递推)
    android api文档:intent阅读笔记
    bitmap相关工具类
  • 原文地址:https://www.cnblogs.com/hudunyu/p/13070075.html
Copyright © 2011-2022 走看看