Mat*_*ten 2 sass angular-material2 angular
我正试图在我的角度项目中使用我的自定义主题.它没有按预期工作,我收到以下错误:
./node_modules/css-loader?{"sourceMap":false,"importLoaders":1}!./node_modules/postcss-loader?{"ident":"postcss"}!./src/custom_theme.scss
Module not found: Error: Can't resolve '@angular/material/theming' in '/Users/mathiasschrooten/Downloads/skylux-admin/src'
Run Code Online (Sandbox Code Playgroud)
我的styles.css文件:
@import "custom_theme.scss"
.mat-tab-label {
flex: 1 1 auto;
}
Run Code Online (Sandbox Code Playgroud)
我的custom_theme.scss文件:
@import '~@angular/material/theming';
@include mat-core();
$candy-app-primary: mat-palette($mat-orange);
$candy-app-accent: mat-palette($mat-orange, A200, A100, A400);
$candy-app-warn: mat-palette($mat-red);
$candy-app-theme: mat-light-theme($candy-app-primary, $candy-app-
accent, $candy-app-warn);
@include angular-material-theme($candy-app-theme);
Run Code Online (Sandbox Code Playgroud)
.angular-cli.json
"styles": [
"styles.css",
"custom_theme.scss"
],
Run Code Online (Sandbox Code Playgroud)
提前致谢!
你可以删除@import "custom_theme.scss"你的styles.css.由于您已将(或v6 +)添加custom_theme.scss到您的导入不是必需的.angular-cli.jsonangular.json
编辑完angular.json文件后,您需要ng-serve再次运行.
根据官方文件:
如果您使用的是Angular CLI,则内置支持将Sass编译为css; 你只需要在angular-cli.json中指向主题文件的"样式"列表中添加一个新条目(例如,unicorn-app-theme.scss).
| 归档时间: |
|
| 查看次数: |
2071 次 |
| 最近记录: |