zoukankan      html  css  js  c++  java
  • 微信6.7.4 ios12 软键盘收回时页面不回弹,导致光标位置错乱,再次点击输入框区域时无法focus

    https://developers.weixin.qq.com/community/develop/doc/00044ae90742f8c82fb78fcae56800

    https://blog.csdn.net/qq_23370345/article/details/84757505

    参考上述文章,可解决,补充多个输入框处理方法:

       /* 问题: ios12+,微信6.7.4版本存在bug,键盘收回时,界面没有恢复,底下出现空白区域,并导致光标位置错乱,再次点击输入框区域时无法focus
             解决方案: 当input失焦,键盘收回后,滚动一下页面就可以使页面恢复正常
             补充: 当在手机号与验证码之间切换输入时,会同时触发前输入框的blur和后输入框focus,这个时候触发滚动,页面会出现较大跳跃,因此通过inFocus 和 setTimeout 判断,是切换input还是真正blur,真正blur的时候,再滚动页面
          */
          //focus
          iptFocus () {
             this.errorMessage = '';
             this.inFocus = true;
          },
          //blur
          iptBlur () {
             let this_ = this;
             this_.inFocus = false;
             setTimeout(function () {
                if(this_.inFocus == false){
                   // 当input 失焦时,滚动一下页面就可以使页面恢复正常
                   this_.checkWxScroll();
                }
             },200)
          },
     
          checkWxScroll(){
             var ua = navigator.userAgent.toLowerCase();
             var u = navigator.userAgent.match(/(i[^;]+;( U;)? CPU.+Mac OS X/);
     
             if(ua.match(/MicroMessenger/i) == 'micromessenger'&&!!u){//在iphone 微信中
    //            var osVersion  =  navigator.userAgent.match(/iPhonesOSs([d\_]+)/i);
    //            var  osArr = osVersion.length>=1? osVersion[1].split('_'):[];
    //            var newOS = osArr.length>=2 && (versionArr[0]>11)
    //            if(newOS){ //如果iphone版本号>=12
                   this.temporaryRepair();
    //            }
             }
          },
          temporaryRepair(){
             var currentPosition,timer;
             var speed=1;//页面滚动距离
             timer=setInterval(function(){
                currentPosition=document.documentElement.scrollTop || document.body.scrollTop;
                currentPosition-=speed;
                window.scrollTo(0,0);//页面向上滚动
    //            currentPosition+=speed; //speed变量
    //            window.scrollTo(0,currentPosition);//页面向下滚动
                clearInterval(timer);
             },1);
          },
  • 相关阅读:
    Linux操作系统基本操作(1)
    C#: 获取当前路径不要用Environment.CurrentDirectory
    Python:Selenium Chrome无弹窗+property/attribute/text
    Python:Selenium+Webdriver安装
    Redis开启远程登录连接
    Redis Error:/var/redis/run/redis_6379.pid exists, process is already running or crashed
    Oracle VM VirtualBox虚拟机内Linux系统硬盘扩容步骤(CentOS6.5)
    PHP开发中Redis安装(CentOS6.5)
    MySQL创建用户与授权(CentOS6.5)
    CentOS下二进制包/源码安装方式的MySQL卸载步骤
  • 原文地址:https://www.cnblogs.com/fqh123/p/10268304.html
Copyright © 2011-2022 走看看