import { Component, OnInit } from '@angular/core'; import { Observable, fromEvent } from 'rxjs'; import { debounceTime } from 'rxjs/operators'; @Component({ selector: 'app-inform', templateUrl: './inform.component.html', styleUrls: ['./inform.component.scss'] }) export class InformComponent implements OnInit { constructor() { } tableSpin = false list = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] tableScrollHeight ngOnInit(): void { this.tableScrollHeight = (document.getElementById('tablebox').clientHeight - 42) + 'px' // 页面监听 fromEvent(window, 'resize').pipe(debounceTime(100)).subscribe((event) => { this.tableScrollHeight = (document.getElementById('tablebox').clientHeight - 42) + 'px' }); } dispose() { console.log('处置') } }