预制的Angular材质主题在库中的工作方式与在Angular应用中不同。在projects / example-lib文件夹中创建了一个style.css文件,并在其中导入了预先构建的靛蓝粉色主题。根据文档,我应该将其包含在angular.json文件中,但是在执行此操作时,出现以下错误
Schema validation failed with the following errors:
Data path "" should NOT have additional properties(styles).
Angular Material设计组件(Mat-Tabs等。)在我的图书馆中可以运行,但是Angular Material主题不起作用。我也尝试将以下内容添加到我的styles.css中,
@import "~@angular/material/prebuilt-themes/indigo-pink.css";
也没有用。我认为,由于style.css文件未全局定义,因此无法应用预制主题。
这是从角材料网站上获得的,可能会有帮助:
最后,如果您的应用程序内容未放置在mat-sidenav-container元素内,则需要将mat-app-background类添加到包装器元素(例如body)。这样可以确保将正确的主题背景应用于您的页面。