>html ~~~ <p>dom works!</p> <p #mybox> {{msg}}</p> ~~~ >component.ts ~~~ import { Component, OnInit,ViewChild } from '@angular/core'; @Component({ selector: 'app-dom', templateUrl: './dom.component.html', styleUrls: ['./dom.component.css'] }) export class DomComponent implements OnInit { @ViewChild('mybox') mybox:any; constructor() { } public msg:string="hello word"; ngOnInit(): void { //组件和指令初始化完成 并不是真正的dom加载完成 } ngAfterViewInit():void{ //dom加载完毕,原生js建议在这里操作 this.mybox.nativeElement.style.color="red"; } } ~~~