Vue监听页面放大缩小事件
Vue监听页面放大缩小事件 ,使用window.addEventListener,methods中方法
ChangeWin(){
let ratio = this.getRatio();
let Pwidth = window.screen.width*this.getRatio()/100;
let PHeight = window.screen.height*this.getRatio()/100;
//1920 *1080
if (ratio == 100) {
if (Pwidth == '1920' && PHeight == '1080') {
this.$el.style.setProperty('--mg_top1', '3.5vh')
}
}
}
使用:
mounted() {
window.addEventListener('resize', this.ChangeWin);
},