Angular ViewEncapsulation
今天在写项目的时候发现一个问题,在自定义组件的.scss文件中添加的样式应用不上。
代码如下:
sp-pay-wait{
.header-wrap{
white-space: normal !important;
text-align: center !important;
}
}
看了一下,最后生成的css样式为:
sp-pay-wait[_ngcontent-c25] .header-wrap[_ngcontent-c25] {
white-space: normal !important;
text-align: center !important;
}
导致样式应用不上,查了一下说是 需要将组件中 encapsulation 设置为 ViewEncapsulation.None。
具体可参考 https://segmentfault.com/a/1190000008677532

浙公网安备 33010602011771号