我开始研究Angular CLI生成的项目,并意识到我忘记了--style=sass
标志。
有没有办法转换我的项目以使用Angular CLI启用SASS?
答案 0 :(得分:8)
您可以在现有项目上设置默认样式
ng set defaults.styleExt scss
并在angular-cli.json文件中将 style.css 更改为 style.scss
"apps":[{
"styles":[
"styles.scss"
]
}]
答案 1 :(得分:4)
在角度cli 6中,这是被剥夺的
ng set defaults.styleExt scss
你应该使用这个
ng config defaults.styleExt = scss
答案 2 :(得分:4)
在Angular 6+中,如果您在执行ng config defaults.styleExt = scss
之后收到控制台警告
之所以这样,是因为single dashes are not supported anymore
Schema validation failed with the following errors:
Data path "" should NOT have additional properties(defaults).
您可以运行以下命令来更改原理图
ng config schematics.@schematics/angular:component.styleext scss
您需要进行两次手动更改
.css
文件重命名为根文件夹中的.scss
"styles": ["src/styles.scss"],
答案 3 :(得分:2)
只需将现有的css文件(如果有的话)重命名为sass并将其添加到angular-cli.json:
//
// main.cpp
// This code doesn't compile
// but it's for clarification purposes
// Created by Måns Nilsson on 2017-01-02.
// Copyright © 2017 Måns Nilsson. All rights reserved.
//
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
int currval;
int otherval;
int arrlength;
cout<<"How many elements would you like to allocate?"<<endl<<"Your input: ";
cin >> arrlength;
int numlist[arrlength];
//User inputs the element values and variables are assigned to
//point directly to each element
for(int i=0;i<arrlength;i++) {
cout<<"Enter a value for element "<<(i + 1)<<": ";
cin >> currval;
numlist[i] = currval;
int &var(i) = numlist[i];
}
cout<<"Enter the index of the element you want to modify: ";
cin >> currval;
cout<<"Enter a new value for element "<<currval<<": ";
cin >> otherval;
var(currval-1) = otherval;
return 0;
}
另请查看此文件中的app / styles部分 - 您也应该在此处重命名文件名