角度材质 - 无法解析“@angular/material/theming" [英] Angular Material - Can't resolve '@angular/material/theming'

查看:27
本文介绍了角度材质 - 无法解析“@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.

  1. styles.css 重命名为 styles.scss 并将其内容设置为 @import './app-theme';
  2. angular-cli.json中,将styles: ["styles.css"]改为styles: ["styles.scss"]
  3. 重启 npm
  1. Rename styles.css to styles.scss and set its content to @import './app-theme';
  2. In angular-cli.json, change styles: ["styles.css"] to styles: ["styles.scss"]
  3. Restart npm

这篇关于角度材质 - 无法解析“@angular/material/theming"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆