zoukankan      html  css  js  c++  java
  • 关于页面input导致页面可滑动问题(iOS上)

    关于页面input导致页面可滑动问题(iOS上)

    安卓关于弹出键盘问题可以用resize解决
    解决方案:滑动页面的时候让对应的input失去焦点(默认滚动不失去焦点)

    1.给input组件添加获取焦点事件,并传人对应input的参数

    @onFocus="onFocus(0)"  //input绑定获取焦点事件
    

    2.追加事件

    onFocus(val){  //获取焦点事件
    this.isScroll=true
       setTimeout(()=>{
                if(this.isScroll){
                  this.inputName=val
                  window.addEventListener('scroll', this.scrollEvent);
                }
              },800)
     }, 
      scrollEvent(){  //滚动事件
       var input1 =document.getElementsByClassName('inputState')[this.inputName]
       input1.blur()
       window.removeEventListener('scroll', this.scrollEvent);
     },
     getBlure(){  //失去焦点事件(过快失去焦点的时候不去绑定事件)
              this.isScroll=false
          },
    

    如果页面有多个input,需要在input失去焦点或者其判断事件触发后移除滚动事件

    3.销毁

       destroyed() {    //清除scroll事件
          window.removeEventListener('scroll', this.scrollEvent);
        },
    
  • 相关阅读:
    MyCat 数据库读写分离
    python 网络编程-05 socketserver
    python 网络编程-04 文件的传输
    python 网络编程-03 粘包问题及处理
    常用模块-01getopt
    js获取自动获取本电脑IP
    js变态需求
    js正则不能输入中文和英文
    禁止输入中文
    手机号3-4-5
  • 原文地址:https://www.cnblogs.com/liuhuanwen/p/8818767.html
Copyright © 2011-2022 走看看