Angular4_获取table/div的高度

import { ElementRef, ViewChild } from '@angular/core';

export class viewApp{

      @ViewChild('mainScreen') elementView: ElementRef;
      viewHeight: number;

      constructor() {
      }

      clickMe(){
        this.viewHeight = this.elementView.nativeElement.offsetHeight;
      }
}
Template:

<div class="view-main-screen" #mainScreen></div>


猜你喜欢

转载自blog.csdn.net/qq_36279445/article/details/80119706