data() {
return {
clientHeight: 0, // 声明data
}
},
methods: {
// 设置页面高度
setClientHight() {
var _this = this;
_this.clientHeight = `${document.documentElement.clientHeight}px`;
// 控制台打印
console.log(_this.clientHeight);
},
},
mounted() {
var _this = this;
// 挂载读取页面高度
_this.setClientHight();
// 窗口页面高度变更
window.onresize = function(){
_this.setClientHight();
}
}