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);
        }
      });
    }
  }
相关推荐
anyup几秒前
支持鸿蒙!开源三个月,uView Pro 开源库近期更新全面大盘点,及未来计划
前端·vue.js·uni-app
BBB努力学习程序设计17 分钟前
用Bootstrap一天搞定响应式网站:前端小白的救命稻草
前端·html
嘴平伊之豬17 分钟前
跟着AI速度cli源码三-交互问答系统
前端·node.js
用户01360875668823 分钟前
前端支持的主要数据类型及其使用方式
前端
代码搬运媛29 分钟前
SOLID 原则在前端的应用
前端
lecepin1 小时前
AI Coding 资讯 2025-11-17
前端
孟祥_成都1 小时前
下一代组件的奥义在此!headless 组件构建思想探索!
前端·设计模式·架构
灰太狼大王灬1 小时前
Telegram 自动打包上传机器人 通过 Telegram 消息触发项目的自动打包和上传。
前端·机器人
疯笔码良1 小时前
【IOS开发】Objective-C 与 Swift 的对比
ios
4***14901 小时前
SpringSecurity登录成功后跳转问题
前端