zoukankan      html  css  js  c++  java
  • vue引入fastClick导致的输入框点击无响应问题

    混合开发过程中,iOS引用前端界面之后,界面点击会默认产生一个300毫秒的延时效果,为了解决这个问题,引入fastClick,但是当界面引入fastClick之后,会产生输入框点击无法获取焦点问题,只有双击或者长按的时候才能使input输入框获取到焦点,该问题是由于引入fastClick导致的,解决方案如下:

    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();

    }

    };

    再引入fastClick的js中加入如上代码即可解决input输入框点击不能获取焦点的问题

  • 相关阅读:
    QGIS 编译
    Ubuntu: 无法使用su命令
    win7 与 Ubuntu 16.04 文件传送
    OSGEarth编译
    GADL配置编译
    C++ 类对象和 指针的区别
    C++ Primer Plus 第六版笔记
    Windows下使用doxygen阅读和分析C/C++代码
    _MSC_VER详细介绍
    LUA学习之一 初次接触
  • 原文地址:https://www.cnblogs.com/chenzxl/p/11567384.html
Copyright © 2011-2022 走看看