【发布时间】:2021-02-14 17:48:14
【问题描述】:
我试图覆盖primeng卡上的一种默认样式,但由于某种原因,当我使用scss文件时,样式未应用。下面是我尝试过的代码,同样的代码适用于 css 文件。
我在模板上有以下代码
<p-card>
<app-component></app-component>
</p-card>
并在 scss 文件上尝试过这个
:host >>> .p-card .p-card-body {
padding: 0.5rem;
}
我在 appComponent 上有这个
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-component',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}
当我使用 css 但不适用于 scss 文件时,相同的样式有效。我还有什么需要做的吗?
【问题讨论】:
-
能否也分享一下组件的template(html)代码?
-
您是否将
styleUrls: ['./app.component.css']替换为styleUrls: ['./app.component.scss']? -
我已经更新了问题