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);
        },
    
  • 相关阅读:
    如何运行vue项目
    java string型时间转long
    龙果学院dubbo
    百度网盘
    百度网盘资源搜索
    charles安装
    charles抓包
    lr报告分析
    一些缩写意思
    带有事务的进入首页、登录、登出脚本
  • 原文地址:https://www.cnblogs.com/liuhuanwen/p/8818767.html
Copyright © 2011-2022 走看看