我正在使用带有 NONE 的 View Encapsulation 但是在 ruuing 代码时它不起作用。这是我的代码。
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
@Component({
selector: 'app-encap-none',
templateUrl: './encap-none.component.html',
styles: [
`
h2{
background: red;
color:#fff;
}
`
]
, encapsulation:ViewEncapsulation.None
})
export class EncapNONEComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}
HTML 文件代码
<h2>Check NONE IS WORKING OR NOT</h2>
当我运行应用程序时,输出就在图像中。 在此处输入图像描述