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); },
标签:Vue,window,let,getRatio,100,监听,页面 From: https://www.cnblogs.com/youmingkuang/p/17354905.html