zoukankan      html  css  js  c++  java
  • 表单在ios下输入框必须重压或长按才能唤起软键盘

    解决方案:

    一、在node_module里找到fastClick文件,然后找到focus方法,加一句focus方法即可解决:
    FastClick.prototype.focus = function(targetElement) {
    var length;
    if (deviceIsIOS && targetElement.setSelectionRange && targetElement.type.indexOf('date') !== 0 && targetElement.type !== 'time' && targetElement.type !== 'month') {
    length = targetElement.value.length;
    targetElement.setSelectionRange(length, length);
    // 修复bug iOS 11.3以上不弹出键盘,加上聚焦代码,让其强聚焦弹窗键盘
    targetElement.focus();
    } else {
    targetElement.focus();
    }
    };


    二、在main.js下加入以下代码:
    const str= navigator.userAgent.toLowerCase()
    const ver=str.match(/cpu iphone os (.*?) like mac os/)

    if (!ver) { // 非IOS系统
    // 引入fastclick 做相关处理
    FastClick.attach(document.body)
    } else {
    if (parseInt(ver[1])< 11) {
    // 引入fastclick 做相关处理
    FastClick.attach(document.body)
    }
    }

    经个人使用,第一种方法有效

    https://segmentfault.com/a/1190000020069345

  • 相关阅读:
    [SQL]数据更新
    Hadoop之mapred
    hadoop之hdfs
    HTML —— 11.25日总结
    HTML —— 11.19日的总结
    三个爬虫的小栗子
    HTML —— video标签
    py爬虫 —— 三个爬虫的小栗子
    HTML —— img标签
    py爬虫 —— py爬虫requests
  • 原文地址:https://www.cnblogs.com/shy1766IT/p/11257760.html
Copyright © 2011-2022 走看看