前置,document.body.clientHeight在标签<!DOCTYPE>的页面里得到的结果是0,所以得用document.documentElement.clientHeigh。刚开始我也纠结了很久,为什么无论怎么变都是0,多次查询后才了解到的。

具体代码:

mounted:function() {

this.screenHeight1=document.documentElement.clientHeight

var that=this

window.οnresize=()=>{

return(()=>{

that.screenHeight=document.documentElement.clientHeight

})()

}

},

watch:{

screenHeight:function(newval,oldval) {

if(newval

this.hidshow=false

}else{

this.hidshow=true

}

}

},

也就是说,在页面可是区域变小的时候把底部给隐藏了。

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐