更新时间:2023-09-30 10:18:58
Angular CLI版本9 (用于创建Angular 9项目)现在从原理图中获取
style
而不是styleext
.使用如下命令:ng config schematics.@schematics/angular:component.style scss
和生成的 angular.json 看起来应该像这样
Angular CLI version 9 (used to create Angular 9 projects) now picks up
style
from schematics instead ofstyleext
. Use the command like this:ng config schematics.@schematics/angular:component.style scss
and the resulting angular.json shall look like this
"schematics": {
"@schematics/angular:component": {
"style": "scss"
}
}
其他可能的解决方案和说明:
要 使用支持sass的角度CLI创建新项目 ,请尝试以下操作:
Other possible solutions & explanations:
To create a new project with angular CLI with sass support, try this:
ng new My_New_Project --style=scss
您也可以使用--style=sass
&如果您不知道两者之间的区别,请阅读本简短的&简单的文章,如果您仍然不知道,只需使用scss
&继续学习.
You can also use --style=sass
& if you don't know the difference, read this short & easy article and if you still don't know, just go with scss
& keep learning.
如果您有一个Angle 5项目,请使用此命令更新项目的配置.
If you have an angular 5 project, use this command to update the config for your project.
ng set defaults.styleExt scss
最新版本
让Angular 6使用CLI在现有项目上设置新样式:
For Angular 6 to set new style on existing project with CLI:
ng config schematics.@schematics/angular:component.styleext scss
或直接进入angular.json:
Or Directly into angular.json:
"schematics": {
"@schematics/angular:component": {
"styleext": "scss"
}
}