且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何修复Angular 2中的错误“找不到Angular Material核心主题"?

更新时间:2023-01-25 19:11:16

您必须将主题导入到全局css或sass文件中:

You have to import a theme into your global css or sass file:

@import "~@angular/material/prebuilt-themes/indigo-pink.css";

或将其包含在您的index.html文件中:

or alternatively include it in your index.html file:

<link href="node_modules/@angular/material/prebuilt-themes/indigo-pink.css" rel="stylesheet">

就像已经提到的主题文档一样,Angular Material提供了以下预先构建的主题:

As in the theming documentation already mentioned Angular Material provides the following pre-built themes:

  • deeppurple-amber.css
  • indigo-pink.css
  • pink-bluegrey.css
  • purple-green.css

您必须包括以下主题之一,或者创建自己的自定义主题.

You have to include one of these themes or you create your own custom theme.