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

    // 解决唤起键盘后焦点定位错位的情况 使用方式@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);
      }
    },

猜你喜欢

转载自www.cnblogs.com/TheHeartWants/p/11514639.html