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();
    }
    };
    集思广益,仅供学习,侵权即删!!
  • 相关阅读:
    windows wsl2 卸载应用
    windows wsl2中ubuntu安装pip3
    href="#"与href="javascript:void(0)"的区别
    JavaScript 变量提升
    虚拟机升级之后.ubuntu找不到网络解决办法
    javascript 全局变量和局部变量
    flask celery使用
    flask magokit使用
    flask 缓存使用
    Linux设置/删除环境变量方法
  • 原文地址:https://www.cnblogs.com/hudunyu/p/13070075.html
Copyright © 2011-2022 走看看