其他分享
首页 > 其他分享> > Vue 实时过去 页面宽高

Vue 实时过去 页面宽高

作者:互联网

mounted() {
    let that = this;
    // <!--把window.onresize事件挂在到mounted函数上-->
    window.onresize = () => {
      return (() => {
        window.fullHeight = document.documentElement.clientHeight;
        window.fullWidth = document.documentElement.clientWidth;
        that.windowHeight = window.fullHeight; // 高
        that.windowWidth = window.fullWidth; // 宽
      })();
    };
  },
watch: {
      windowHeight (val) {
        let that = this;
        // console.log("实时屏幕高度:",val, that.windowHeight );
      },
      windowWidth (val) {
        let that = this;
        // console.log("实时屏幕宽度:",val, that.windowHeight );
      }
    },
data() {
    return {
      circleUrl:
        "https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png",
      size: "small",
      isCollapse: false,
      windowWidth: document.documentElement.clientWidth, //实时屏幕宽度
      windowHeight: document.documentElement.clientHeight //实时屏幕高度
    };
  },

 

标签:Vue,documentElement,val,宽高,实时,window,windowHeight,document,页面
来源: https://www.cnblogs.com/wangshishuai/p/12727150.html