问题页面:
解决demo:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>input输入导致的定位问题</title>
<script src="https://cdn.bootcss.com/vue/2.4.2/vue.min.js"></script>
<style>
body,
html {
width: 100%;
height: 100%;
position: relative;
padding: 0;
margin: 0;
}
</style>
</head>
<body>
<div id="index">
<div style="width:100%;height: 100%;position: relative;overflow: auto;padding:10px;padding-bottom: 50px;box-sizing: border-box;">
input框:<input type="text">
</div>
<div v-show="isShow" style="width: 100%;height: 40px;line-height: 40px;position: absolute;bottom: 0;background-color: #09d;color: #fff;text-align: center;">提交</div>
</div>
<script>
var vm = new Vue({
el: "#index",
data: {
screenHeight: document.body.clientHeight,
clientHeight: document.body.clientHeight,
isShow: true,
},
mounted() {
const that = this
window.onresize = () => {
return (() => {
window.screenHeight = document.body.clientHeight
that.screenHeight = window.screenHeight
})()
}
},
watch: {
screenHeight(val) {
if (this.clientHeight != val) {
this.isShow = false;
} else {
this.isShow = true;
}
}
},
})
</script>
</body>
</html>