找不到 Angular Material 核心主题 - 如何将 Angular Material css 添加到 Liferay Portlet

Could not find Angular Material core theme - How to add Angular Material css to Liferay Portlet

我正在构建一个使用 angular material 输入的 Liferay Angular portlet,并且一些输入根本无法很好地呈现。我猜有些 CSS/JS 不见了,但我不知道到底是什么。

我的样式 css 文件如下所示:

@import "~@angular/material/prebuilt-themes/deeppurple-amber";

此外,当我使用 Developer 工具检查时,我看到以下警告:

Could not find Angular Material core theme. Most Material components may not work as expected.

我还尝试使用 styleUrls: ["/o//lib/app/styling.css"] 从 AppComponent 引用 css 文件,但是运气不好。

所以,我的问题是 - 如何在 Liferay 中的 Angular Portlet 中引用 CSS 文件?

看了一遍又一遍this文章,最后做了如下修改:

  1. styling.css 文件更改为 styling.scss
  2. 将其内容更改为 @import "../../../../../node_modules/@angular/material/prebuilt-themes/deeppurple-amber"; - 我不确定为什么需要 ../ 中的 5 个,我希望通过使用 ~ 来了解 node_modules 文件夹的位置是
  3. 在我的 Portlet 中 @Component 注释的 property 属性中添加了以下行: "com.liferay.portlet.header-portlet-css=/lib/app/styling.css" - 是的,扩展名是 .css 而不是 .scss