我正在尝试在我的角度项目中使用我的自定义主题。它没有按预期工作,我收到以下错误:
./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'
我的 styles.css 文件:
@import "custom_theme.scss"
.mat-tab-label {
flex: 1 1 auto;
}
我的 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);
.angular-cli.json
"styles": [
"styles.css",
"custom_theme.scss"
],
提前致谢!
您可以删除@import "custom_theme.scss"
从你的styles.css
。既然您已经添加了custom_theme.scss
给你的angular-cli.json
(or angular.json
对于 v6+)不需要导入。
编辑后angular.json
file, 你需要跑ng-serve
again.
根据官方文档 https://material.angular.io/guide/theming#defining-a-custom-theme:
如果您使用 Angular CLI,则支持将 Sass 编译为 css
内置;您只需将新条目添加到“样式”列表中
angular-cli.json 指向主题文件(例如,
独角兽应用程序主题.scss)。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)