美文网首页
ios系统键盘收起时的页面对齐

ios系统键盘收起时的页面对齐

作者: Rose_yang | 来源:发表于2021-06-21 20:25 被阅读0次
         <Field v-model="name" clearable @focus="inputFocus"/>
    
    
     mounted () {
        this.ioskeyBoardFix()
      },
    
     ioskeyBoardFix () { // ios系统键盘收起时的页面对齐
          let _this = this
          document.body.addEventListener('focusout', () => {
            let u = window.navigator.userAgent
            let isIos = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)
            if (!isIos) {
              return false
            }
            _this.scrollTimer = setTimeout(() => {
              window.scrollTo({
                top: 0,
                behavior: 'smooth'
              })
            }, 300)
          })
        },
      inputFocus () {
          if (this.scrollTimer) {
            clearTimeout(this.scrollTimer)
            this.scrollTimer = null
          }
        },
    

    相关文章

      网友评论

          本文标题:ios系统键盘收起时的页面对齐

          本文链接:https://www.haomeiwen.com/subject/kuywahtx.html