角度材质 - 无法解析“@angular/material/theming" [英] Angular Material - Can't resolve '@angular/material/theming'
问题描述
我遵循了官方指南并创建了一个app-theme.scss
具有以下内容:
I have followed the official guide and created a app-theme.scss
with the following content:
@import '~@angular/material/theming';
@include mat-core();
$candy-app-primary: mat-palette($mat-indigo);
$candy-app-accent: mat-palette($mat-pink, 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);
styles.css
的内容:
@import './app-theme.scss';
但是,我在编译过程中总是遇到以下错误:Module not found: Error: Can't resolve '@angular/material/theming'
.我必须怎么做才能让它发挥作用?
However, I always get the following error during compilation: Module not found: Error: Can't resolve '@angular/material/theming'
. What must I do to make it work?
推荐答案
已解决:
Angular Material 2 文档假定您默认使用 sass 样式表.这从来没有被清楚地传达或解释过.下面列出的步骤可用于解决此问题.
The Angular Material 2 documentation assumes you are using sass style-sheets by default. This is never clearly communicated or explained. The steps listed below can be used to resolve this issue.
- 将
styles.css
重命名为styles.scss
并将其内容设置为@import './app-theme';
- 在
angular-cli.json
中,将styles: ["styles.css"]
改为styles: ["styles.scss"]
- 重启 npm
- Rename
styles.css
tostyles.scss
and set its content to@import './app-theme';
- In
angular-cli.json
, changestyles: ["styles.css"]
tostyles: ["styles.scss"]
- Restart npm
这篇关于角度材质 - 无法解析“@angular/material/theming"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!