我试图通过处理两个主题来为我自己的组件设置主题。
所以我写了下面的代码。这是主题.scss
@import '~@angular/material/theming';
@include mat-core();
$theme-primary: mat-palette($mat-blue);
$theme-accent: mat-palette($mat-grey, A200, A100, A400);
$theme-warn: mat-palette($mat-red);
$theme: mat-light-theme($theme-primary, $theme-accent, $theme-warn);
$theme-dark: mat-dark-theme($theme-primary, $theme-accent, $theme-warn);
.theme {
@include angular-material-theme($theme);
}
.theme-dark {
@include angular-material-theme($theme-dark);
}
我写了一个简单的组件。这是hello.component.scss
@import './../theme.scss';
@mixin change-color($theme) {
$config: mat-get-color-config($theme);
$primary: map-get($config, primary);
$accent: map-get($config, accent);
:host {
background-color: mat-color($accent, 100);
}
}
:host {
color: red
}
这里的问题是,无论我是否更改主题,颜色都是固定的。
我想使用某种色调的颜色,当我切换到深色主题模式时,它会变成另一种颜色。
是否可以 ?如何 ?
感谢您的帮助