vue页面自适应浏览器高度
- 获取浏览器高度
data(){
return{
fullHeight: document.documentElement.clientHeight
}
},
- 动态获取浏览器高度
watch: {
fullHeight (val) {
if(!this.timer) {
this.fullHeight = val
this.timer = true
let that = this
setTimeout(function (){
that.timer = false
},400)
}
}
},
mounted () {
this.get_bodyHeight()
},
methods :{
get_bodyHeight () {
const that = this
window.onresize = () => {
return (() => {
window.fullHeight = document.documentElement.clientHeight
that.fullHeight = window.fullHeight
})()
}
}
}
- 设置样式
:style="'height:'+(fullHeight*0.93)+'px;'"