data() {
return {
docmHeight: document.documentElement.clientHeight,
showHeight: document.documentElement.clientHeight,
hideClass: false,
}
},
methods{
// 检测屏幕高度变化
inputType() {
if (!this.timer) {
this.timer = true
const that = this
setTimeout(() => {
if (that.docmHeight > that.showHeight) {
// 显示class
this.hideClass = true
} else if (that.docmHeight <= that.showHeight) {
// 显示隐藏
this.hideClass = false
}
that.timer = false
}, 20)
}
},
}
mounted() {
// window.onresize监听页面高度的变化
window.onresize = () => (() => {
window.screenHeight = document.body.clientHeight
this.showHeight = window.screenHeight
})()
},