vue解决方法
<!--html部分-->
<div class="footer" v-show="hideshow"></div>
data(){
return {
docmHeight: document.documentElement.clientHeight,
showHeight: document.documentElement.clientHeight,
hideshow:true,
}
},
mounted() {
window.onresize = ()=>{
return(()=>{
this.showHeight = document.body.clientHeight;
})()
}
},
watch:{
showHeight:function() {
if(this.docmHeight > this.showHeight){
this.hideshow=false
}else{
this.hideshow=true
}
}
}
js解决方案
var winHeight = $(window).height();
$(window).resize(function () {
var thisHeight = $(this).height();
if ( winHeight - thisHeight > 140 ) {
$('.footer').css('position','static');
} else {
$('.footer').css({'position':'fixed','bottom':'0'});
}
})