ngAfterViewInit(){//推荐在此生命周期函数中操作DOM}
1.ViewChild
//1.给DOM命名<div #app *ngIf="flag">显示</div>//2.配置ViewChildimport { Component, OnInit,ViewChild } from '@angular/core';export class AboutComponent implements OnInit {@ViewChild('app',{static:false}) app:any;ngAfterViewInit(){console.log(this.app);}}
