角材料-无法解析'@ angular/material/theming' [英] Angular Material - Can't resolve '@angular/material/theming'
本文介绍了角材料-无法解析'@ 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';
但是,在编译过程中总是会出现以下错误:找不到模块:错误:无法解析'@ 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.css"]
更改为样式:["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屋!
查看全文