软键盘遮挡

This commit is contained in:
2022-06-28 19:12:31 +08:00
parent 79e02ee0fc
commit ee5b1d0ac0
8 changed files with 211 additions and 17 deletions

View File

@@ -1,7 +1,7 @@
<template>
<section>
<nav-bar title="清洗组桶标签打印"></nav-bar>
<section class="content mgt186">
<section class="content mgt186" ref="content">
<div class="filter-wraper">
<search-box
label="装入桶"
@@ -35,7 +35,7 @@
<div class="bottom-filter-tip">
<div class="filter-label txtjustify">桶数</div>
<div class="fxcol mgl20">
<input type="text" class="filter-input filter-scan-input" v-model="val5">
<input type="text" class="filter-input filter-scan-input" v-model="val5" @focus="windowScrollTo($event)" @blur="windowsScrollTopZero">
</div>
</div>
</div>
@@ -89,6 +89,25 @@ export default {
this._getpcsn()
},
methods: {
windowScrollTo (e) {
// 可见窗口高
let innerHeight = 6.12 * parseFloat(document.documentElement.style.fontSize)
// 元素底部到可视窗口的距离
let elHeight = e.target.getBoundingClientRect().bottom
if (elHeight > innerHeight) {
let mgb = elHeight - innerHeight
this.$refs.content.style.marginBottom = mgb + 'px'
setTimeout(() => {
window.scrollTo(0, mgb)
}, 100)
}
},
windowsScrollTopZero () {
this.$refs.content.style.marginBottom = '0px'
setTimeout(() => {
window.scrollTo(0, 0)
}, 100)
},
handleChange (e, type) {
if (type) {
this._queryInfoBybucket2(e)
@@ -199,3 +218,9 @@ export default {
}
}
</script>
<style lang="stylus" scoped>
.content
height calc(100% - 1.86rem)
overflow hidden
</style>