ios 输入法覆盖输入框,利用focus事件触发,利用滚动条底部位置定位
来源:互联网 发布:知敬畏守底线思想认识 编辑:程序博客网 时间:2024/06/06 01:50
经过自己测试:
ios下不能监听resize事件,但是dom元素可以相应focus事件。
利用focus事件触发:
<textarea @focus="handleResize" class="weui-textarea" rows="1" v-model.trim= "commentInput" placeholder="添加评论" />
方法一:
滑动到底部,可以将输入框往上提升显示出来。
handleResize: function () { // var self = this setTimeout(function () { // document.body.scrollTop = (parseInt(document.documentElement.clientHeight) - 50) // window.scrollTo(0, document.body.scrollTop) document.body.scrollTop = (parseInt(document.body.scrollHeight) - 50) window.scrollTo(0, document.body.scrollTop) }, 400)},
方法二:
nextTick渲染出来之后,再去延迟处理滚动到可视区域。
handleResize: function () { this.$nextTick(function () { setTimeout(function () { document.getElementById('applyNote').scrollIntoView(true) }, 400) })},
方法三:
下面是转自其他人的记录,没有测试成功过,未知是否有效。
https://www.cnblogs.com/pengshengguang/p/7765079.html
<ul id="applyNote" v-else> <li style="float:left; width:80%"> <div class="inputComment"> <textarea class="weui-textarea" @focus="handleResize" rows="1" v-model.trim= "commentInput" placeholder="添加评论" /> </div> </li> <li style="position:absolute;width:20%; right:0; bottom:0; padding-right:20px; padding-bottom:10px;" > <a @click="commentSubmitClick(curCommentId, curToName)"><img v-bind:src="plSubmitIcon" /></a> </li></ul>
docmHeight: document.documentElement.clientHeight,showHeight: document.documentElement.clientHeight,
handleResize: function () { window.screenHeight = document.body.clientHeight this.showHeight = window.screenHeight},
inputType () { if (!this.timer) { this.timer = true let that = this setTimeout(() => { if (that.docmHeight > that.showHeight) { that.inputfile = false if (document.activeElement.className === 'weui-textarea') { document.getElementById('applyNote').scrollIntoViewIfNeeded() // 输入框的id为applyNote,class为weui-textarea } } else if (that.docmHeight <= that.showHeight) { that.inputfile = true } that.timer = false }, 20) }}
watch: {
showHeight:
'inputType'
,
}
方法四:
https://www.zhihu.com/question/32746176
阅读全文
0 0
- ios 输入法覆盖输入框,利用focus事件触发,利用滚动条底部位置定位
- jquery滚动条到底部触发事件
- js实现滚动条滚动到最底部触发事件
- css 滚动条滑动到底部时触发事件
- 利用jquery制作滚动到指定位置触发动画
- 滚动条分页/滚动条事件触发
- jquery 滚动条 触发事件
- 滚动条移动触发事件
- 滚动条下拉触发事件
- 怎么定位滚动条位置
- 定位滚动条的位置
- 定位底部的输入框被软键盘覆盖解决方案
- 利用本地存储实现记录滚动条的位置
- 关于滚动条滚动到指定位置触发jq事件和html锚点
- angularJS-滚动到底部触发事件
- 关于IE10输入框focus后触发input事件的bug
- asp.net2003页面触发事件如何控制滚动条的位置
- 判断滚动条是否到达底部事件
- 使用现有库
- kivy properties模块报错
- iptables之显式扩展
- 数据库管理
- intellij idea取消重复代码提醒的功能
- ios 输入法覆盖输入框,利用focus事件触发,利用滚动条底部位置定位
- java poi Excel内图片获取存储并关联数据入库
- vue的匿名插槽
- 自定义ELF,使得自动做初始化
- ContentProvider
- zabbix snmp监控交换机流量
- 【Scikit-Learn 中文文档】交叉分解
- 关于盒子垂直居中的一些小技巧
- 主机与附加配置文件不符