vue H5页面在微信浏览器打开软键盘关闭导致页面空缺的问题。

methods:{
    inputBlur () {
      // window.scroll(0, 0);
      setTimeout(() => {
        // alert(1);
        if (document.activeElement.tagName === 'INPUT' || document.activeElement.tagName === 'TEXTAREA') {
          return;
        }
        if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) { // 判断iPhone|iPad|iPod|iOS
          this.valRes = 'ios';
        } else if (/(Android)/i.test(navigator.userAgent)) { // 判断Android
          this.valRes = 'android';
        }
        if (this.valRes === 'ios') {
          document.activeElement.scrollIntoViewIfNeeded(true);
        }
      }, 10);
    },

}

input失焦事件:
<input  @blur="inputBlur" />
 
  
 
 

猜你喜欢

转载自www.cnblogs.com/skin-blue/p/10341836.html