移动端监听横屏竖屏

window.addEventListener(
    'onorientationchange' in window ? 'orientationchange' : 'resize',
        that.getScreenStatus,
        false
      );
if (this.orientation === 180 || this.orientation === 0) {
  if (this.direction === 'horizontal') {
      this.$refs.coursePreview.className = 'progess-MinHeight';
      this.$refs.progressCicle.style.left = this.$refs.progressBar.style.width;
        }
      }
      //判断横屏
if (this.orientation === 90 || this.orientation === -90) {
    if (this.direction === 'horizontal') {
      this.$refs.coursePreview.style.height =
          document.getElementsByClassName('img_c1')[0].style.height + 'px';
          this.$refs.progressCicle.style.left = this.$refs.progressBar.style.width;
      }
}

你可能感兴趣的:(移动端监听横屏竖屏)