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输入框点击不能获取焦点的问题

  • 相关阅读:
    小知识!
    命令级的python静态资源服务。
    自定义滚动条样式-transition无效
    css:a:visited限制
    react16 渲染流程
    virtual-dom
    用video标签流式加载
    golang 代码笔记
    position:fixed not work?
    go/node/python 多进程与多核cpu
  • 原文地址:https://www.cnblogs.com/chenzxl/p/11567384.html
Copyright © 2011-2022 走看看