简体   繁体   English

将scss文件添加到Stackblitz

[英]Add scss file to the Stackblitz

Can you tell me how to add scss file to the stackblitz . 你能告诉我如何将scss文件添加到stackblitz I tried that.But it is not working. 我试过了。但它不起作用。 Please see that and let me know. 请看到并告诉我。

I have tried to add home.html 我试图添加home.html

This is the project: stackblitz 这是项目: stackblitz

Scss should work in stackblitz : Scss应该在stackblitz中工作

@Component({
  selector: 'page-home',
  templateUrl: 'home.html',
  styleUrls: [ './home.scss' ] <== add this
})
export class HomePage {

Styles like 风格如

 page-home {
 .buttoncls {

won't work for you with default encapsulation( ViewEncapsulation.Emulated ) because page-home is not part of home component template and angular adds attribute like [_ngcontent-c0] to styles. 默认封装( ViewEncapsulation.Emulated )不适合您,因为page-home不是home组件模板的一部分,而angular将[_ngcontent-c0]等属性添加到样式中。

So we can change page-home to ion-list and see how it works: 所以我们可以将page-home更改为ion-list并查看它是如何工作的:

Stackblitz Example (ViewEncapsulation.Emulated) Stackblitz示例(ViewEncapsulation.Emulated)

But we can disable encapsulation: 但我们可以禁用封装:

encapsulation: ViewEncapsulation.None

Stackblitz Example (ViewEncapsulation.None) Stackblitz示例(ViewEncapsulation.None)

See also this thread 另见此主题

https://github.com/stackblitz/core/issues/1 https://github.com/stackblitz/core/issues/1

As EricSimons commented 9 days ago: 正如EricSimons在9天前评论过的那样:

Hey all! 大家好! We just shipped SASS and LESS support, and we also support the angular-cli.json config too :) 我们刚刚发布了SASS和LESS支持,我们也支持angular-cli.json配置:)

Above answer does not work anymore. 以上答案不再适用。 Update: 更新:

@Component({
  selector: 'page-home',
  templateUrl: 'home.html',
  styleUrls: [ 'home.scss' ] <== add this
})

Also - the styles must go in the most outside block and shouldn't go under other block. 此外 - 样式必须在最外面的块中,不应该在其他块下面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM