当前位置:网站首页>app内嵌h5---iphone软键盘遮挡输入文字
app内嵌h5---iphone软键盘遮挡输入文字
2022-07-06 22:39:00 【Kratial】
1.产生问题的原因
在ios中,软键盘在页面最上层,软键盘的弹起不会引起窗口高度的变化,故而会遮挡原本处于最底部的输入框。
但是在android下,软键盘与窗口处于同一层,所以当软键盘弹起时,当前窗口会发生变化,故而不存在这个问题。
2.如何监听软键盘的弹出和隐藏
在ios中聚焦的时候软键盘会弹起,失去焦点的时候软键盘会收起
3.解决方案
(1)scrollIntoView
(2)监听聚焦和失焦的情况
(3)使用这个scrollIntoView,需保证当前输入框在原本的可视区域外
handleFocus(elem) {
console.log('软键盘弹起')
document.body.style.height = '100vh' + 软键盘高度
document.querySelector('.' + elem).scrollIntoView();
}
},
handleBlur() {
document.body.style.height = '100%'
console.log('软键盘隐藏')
}
4.关于scrollIntoView的介绍
Element 接口的 scrollIntoView() 方法会滚动元素的父容器,使被调用 scrollIntoView() 的元素对用户可见。
参考链接:MDN—scrollIntoView
边栏推荐
- Using thread class and runnable interface to realize the difference between multithreading
- Comparison between thread and runnable in creating threads
- [digital analog] source code of MATLAB allcycles() function (not available before 2021a)
- How to choose an offer and what factors should be considered
- 关于01背包个人的一些理解
- Station B boss used my world to create convolutional neural network, Lecun forwarding! Burst the liver for 6 months, playing more than one million
- Markdown编辑器
- 日常工作中程序员最讨厌哪些工作事项?
- When knative meets webassembly
- DFS and BFS concepts and practices +acwing 842 arranged numbers (DFS) +acwing 844 Maze walking (BFS)
猜你喜欢
九章云极DataCanvas公司摘获「第五届数字金融创新大赛」最高荣誉!
01机器学习相关规定
AttributeError: module ‘torch._ C‘ has no attribute ‘_ cuda_ setDevice‘
Depth first traversal template principle of tree and graph
How to package the parsed Excel data into objects and write this object set into the database?
【线段树实战】最近的请求次数 + 区域和检索 - 数组可修改+我的日程安排表Ⅰ/Ⅲ
Ansible中的inventory主机清单(预祝你我有数不尽的鲜花和浪漫)
5G VoNR+之IMS Data Channel概念
In depth analysis of kubebuilder
Lessons and thoughts of the first SQL injection
随机推荐
Markdown editor
史上最全学习率调整策略lr_scheduler
If you‘re running pod install manually, make sure flutter pub get is executed first.
Function pointer and pointer function in C language
Pointer and array are input in function to realize reverse order output
Flask project uses flask socketio exception: typeerror: function() argument 1 must be code, not str
Local tool [Navicat] connects to remote [MySQL] operation
3GPP信道模型路损基础知识
窗口可不是什么便宜的东西
Structure actual training camp | after class homework | module 6
A line of R code draws the population pyramid
A picture to understand! Why did the school teach you coding but still not
Why do many people misunderstand technical debt
Vscode automatically adds a semicolon and jumps to the next line
How does vscade use the built-in browser?
A row of code r shows the table of Cox regression model
计数排序基础思路
【愚公系列】2022年7月 Go教学课程 005-变量
Read of shell internal value command
Servicemesh mainly solves three pain points