>component.ts ~~~ import { Component, OnInit } from '@angular/core'; @Component({ selector: 'app-header', templateUrl: './header.component.html', styleUrls: ['./header.component.css'] }) export class HeaderComponent implements OnInit { public html:string='<h4>html 的标签h4</h4>'; constructor() { } ngOnInit(): void { } } ~~~ > html ~~~ <div> <!-- 被转义输出实体字符--> {{html}} </div> <div [innerHTML]="html"> <!-- 直接解析为html--> </div> ~~~