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();
    }
    };
    集思广益,仅供学习,侵权即删!!
  • 相关阅读:
    Python 初识爬虫-**机场出港业务
    Python 基础学习之字典
    Python 基础学习之if语句
    初识 超级账本
    搭建element-ui Vue结构
    回归
    Gin框架body参数获取
    log4go折腾
    go获取当前执行的位置程序
    mybatis generator 整合lombok
  • 原文地址:https://www.cnblogs.com/hudunyu/p/13070075.html
Copyright © 2011-2022 走看看