在生命周期函数中监听窗口变化
mounted() {
var _this = this;
window.onresize = function(){
// 定义窗口大小变更通知事件
console.log('--------------onresize---------------')
_this.getWH();
};
},
监听到窗口变化时调用方法:
getWH(){
var clientWidth = document.body.clientWidth // 网页可见区域宽:
var clientHeight = document.body.clientHeight // 网页可见区域高:
var offsetWidth = document