问题描述
$npm install -g @angular/cli
$ng new angular --routing --style=sass
$ng g c home
"apps": [
{
"styles": [
"styles.sass"
],
}
"defaults": {
"styleExt": "sass",
"component": {
}
}
我想在 angular 中使用 sass 样式,我使用 angular cli,我尝试生成它返回的带有前缀 css 的样式的组件.你能帮我解决这个问题吗?预先感谢您的回答.
I want to sass style in angular, I use angular cli, I try to generate component it returns with style with prefix css. May you help me to fixing that? Thanks in advance for your answer.
推荐答案
我刚从 @angular/cli@1.0.3
迁移到 @angular/cli@1.4.2
代码>,我面临同样的问题.原来这是由于 v1.4.1 中引入的一个错误,所以我们只能等待一个新的 angular-cli 版本来修复这个错误.在 v1.4.1 中,apps.prefix
也被忽略,但这在 v1.4.2 中已修复.
I just migrated from @angular/cli@1.0.3
to @angular/cli@1.4.2
and I am facing the same issue. Turns out it's due to a bug introduced in v1.4.1 so we can only wait for a new angular-cli release that will fix this bug.In v1.4.1 also the apps.prefix
is ignored but this was fixed in v1.4.2.
同时,可以使用@Derlin 提供的解决方法.
In the mean time, the workaround provided by @Derlin can be used.
关于这个主题的 github 问题:
github issues on this topic:
- https://github.com/angular/angular-cli/issues/7624
- https://github.com/angular/angular-cli/issues/7682
- https://github.com/angular/angular-cli/issues/7644
- https://github.com/angular/angular-cli/issues/7647
- https://github.com/angular/angular-cli/issues/7522
更新:
该问题已在 @angular/cli@1.4.3
中修复.查看本发行说明.
The issue is fixed in @angular/cli@1.4.3
. Check this release note.
@angular/cli: 生成组件考虑默认样式扩展现在为项目
这篇关于@angular/cli: 1.4.1 Angular Generate Component 但它返回 home.component.css的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!