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);
        }
      });
    }
  }
相关推荐
用户2141183263602几秒前
dify案例分享-用 Dify 一键生成教学动画 HTML!AI 助力,3 分钟搞定专业级课件
前端
没逛够30 分钟前
Vue 自适应高度表格
javascript·vue.js·elementui
太过平凡的小蚂蚁2 小时前
Kotlin 协程中常见的异步返回与控制方式(速览)
开发语言·前端·kotlin
苹果醋33 小时前
JAVA面试汇总(二)多线程(五)
运维·vue.js·spring boot·nginx·课程设计
咖啡の猫3 小时前
Vue初始化脚手架
前端·javascript·vue.js
一 乐3 小时前
汽车销售|汽车推荐|基于SprinBoot+vue的新能源汽车个性化推荐系统(源码+数据库+文档)
java·数据库·vue.js·汽车·毕设·汽车个性化推荐
晨枫阳3 小时前
uniapp兼容问题处理总结
前端·vue.js·uni-app
ii_best3 小时前
按键精灵安卓/iOS脚本辅助,OpenCV实现自动化高效率工具
ios·自动化·编辑器·安卓
蒲公英少年带我飞4 小时前
iOS底层原理:Method Swizzling原理和注意事项
ios