改变 窗口大小时 让页面刷新

 //窗口大小变化时候,进行刷新页面操作,防止样式混乱
var x=window.innerWidth;
 function resizeFresh(){
         if(x!=window.innerWidth){
                location.reload();
 }

<body onresize="resizeFresh()"></body>

    

vue中:

在computed计算属性中:

windowX(){
  var x=window.innerWidth;
  return x;
},
windowY(){
  var y=window.innerHeight;
  return y;
}
在methods中:
windowHeight(){// 适配窗口高度
  if(this.windowX!=window.innerWidth || this.windowY!=window.innerHeight){
    location.reload()
  }
 }
 
在mounted中:
  this.windowHeight();// 适配窗口高度
window.onresize=function(){
  self.windowHeight();//调节轮播图盒子高度
};
原文地址:https://www.cnblogs.com/fqh123/p/9948285.html