[英]Import Error on Stackblitz when trying to add component to module file
[英]Add scss file to the Stackblitz
Scss应该在stackblitz中工作 :
@Component({
selector: 'page-home',
templateUrl: 'home.html',
styleUrls: [ './home.scss' ] <== add this
})
export class HomePage {
风格如
page-home {
.buttoncls {
默认封装( ViewEncapsulation.Emulated
)不适合您,因为page-home
不是home
组件模板的一部分,而angular将[_ngcontent-c0]
等属性添加到样式中。
所以我们可以将page-home
更改为ion-list
并查看它是如何工作的:
Stackblitz示例(ViewEncapsulation.Emulated)
但我们可以禁用封装:
encapsulation: ViewEncapsulation.None
Stackblitz示例(ViewEncapsulation.None)
另见此主题
https://github.com/stackblitz/core/issues/1
正如EricSimons在9天前评论过的那样:
大家好! 我们刚刚发布了SASS和LESS支持,我们也支持angular-cli.json配置:)
以上答案不再适用。 更新:
@Component({
selector: 'page-home',
templateUrl: 'home.html',
styleUrls: [ 'home.scss' ] <== add this
})
此外 - 样式必须在最外面的块中,不应该在其他块下面。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.