vue使用vant中的popup层,在popup层中加搜索功能后,input框获取焦点 ios机型的软键盘不会将popup顶起来的问题

1.使用vant的popup弹出层做了一个piker的选择器,用户需要在此基础上增加筛选功能。也就是输入框
在这里插入图片描述
2.可是在ios机型中,input框在获取焦点以后,ios的软键盘弹起会遮盖住我们的popup层,导致体验不是很好
3.在大佬的解答及帮助下,采用窗口滚动的方式解决此方法

<Popup
          v-model="personalClassificationPoup"
          position="bottom"
          class="per_class_scroll_view"
          round
          get-container="#AppMainContainer"
          safe-area-inset-bottom
          @closed="personalClassificationPoupClosed"
        >
          <Picker
            class="warpPiker"
            show-toolbar
            title="请选择"
            :columns="personalClassificationColumns"
            :defaultIndex="personalClassificationColumnsIndex"
            value-key="TypeName"
            @confirm="(value) => onPersonalPoupConfirm(value)"
            @cancel="() => (personalClassificationPoup = false)"
          >
            <template #title>
              <input 
                v-model="personalClassificationKey"
                type="text"
                @focus="getFocus"
                @input="personalClassificationUpdate" 
                placeholder="请输入搜索内容" 
                class="van-field__control" 
                style="flex:1;text-align:center">
            </template>
          </Picker>
        </Popup>

4.在获取焦点时 将整个窗口的滚动高度赋值为 popup层的高度

getFocus(){
    let events = navigator.userAgent;
    // iphone手机 软键盘第一次顶不起来
    if(events.indexOf('iPhone')>-1){
      this.$nextTick(() => {
        let documents:any = document
        if(documents == undefined || documents == null){
          return
        }
        if(documents.activeElement.tagName === 'INPUT' || documents.activeElement.tagName === 'TEXTAREA'){
            window.setTimeout(function () {
            documents.scrollingElement.scrollTop = documents.querySelector('.per_class_scroll_view').scrollHeight;
          }, 200);
        }
      });
    }
  }
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值