vue获取屏幕的实时 宽度 / 高度

mounted () {
    const that = this;
    window.onresize = () => {
      return (() => {
        window.screenWidth = document.documentElement.clientWidth; //实时宽度
        window.screenHeight = document.documentElement.clientHeight; //实时高度
        console.log(this.screenWidth, this.screenHeight);
        that.screenWidth = window.screenWidth;
        that.screenHeight = window.screenHeight;
      })();
    };
  },

获取屏幕的宽度和高度  适用于响应式 用来做判断使用

你可能感兴趣的:(vue,vue.js,javascript)