移动端唤起键盘后焦点错位的情况

北城余情 提交于 2019-11-29 10:18:58
    // 解决唤起键盘后焦点定位错位的情况 使用方式@blur='blurhandler'
    blurhandler(){
      let ua = window.navigator.userAgent;
      if(!!ua.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)){ // ios 端
          var currentPosition,timer;
          var speed=1;
          timer=setInterval(function(){
            currentPosition=document.documentElement.scrollTop || document.body.scrollTop;
            currentPosition-=speed;
            window.scrollTo(0,currentPosition);//页面向上滚动
            // currentPosition+=speed;
            // window.scrollTo(0,currentPosition);//页面向下滚动
            clearInterval(timer);
          },100);
      }
    },

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!