<template>
<div class="app">
<input type="text" />
<div class="btn" v-if="isShow"></div>
</div>
</template>
<script>
export default {
data () {
return {
docmHeight: document.documentElement.clientHeight || document.body.clientHeight,
showHeight: document.documentElement.clientHeight || document.body.clientHeight,
isShow: true
}
},
mounted () {
window.addEventListener('resize', this.listenResize);
},
watch: {
showHeight: function () {
if (this.docmHeight > this.showHeight) {
this.isShow = false;
} else {
this.isShow = true;
}
}
},
methods: {
listenResize () {
this.showHeight = document.body.clientHeight;
}
},
beforeDestroy () {
window.removeEventListener('resize', this.listenResize);
},
}
</script>
<style lang="less" scoped>
.app {
width: 100%;
height: 100vh;
background-color: #f6f6f6;
.btn {
width: 50%;
height: 50px;
background-color: rgb(255, 255, 255);
position: fixed;
bottom: 0;
}
}
</style>