如下所示卡片组件中 button 没有使用 indigo 与 pink 样式,请问如何解决?
app.component.html
<mat-card class="example-card">
<mat-card-actions>
<button mat-raised-button color="primary">LIKE</button>
<button mat-raised-button color="accent">SHARE</button>
</mat-card-actions>
</mat-card>
styles.scss
@use '@angular/material' as mat;
@include mat.core();
$light-app-theme: mat.define-light-theme((
color: (
primary: mat.define-palette(mat.$indigo-palette),
accent: mat.define-palette(mat.$pink-palette, A200, A100, A400),
warn: mat.define-palette(mat.$red-palette),
)
));
@include mat.core-theme($light-app-theme);
@include mat.button-theme($light-app-theme);
@include mat.card-theme($light-app-theme);
页面输出效果
是没有 import MatButtonModule
引起的,添加引用后立马解决
app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MatButtonModule } from '@angular/material/button';
import { MatCardModule } from '@angular/material/card';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule,
BrowserAnimationsModule,
MatCardModule,
MatButtonModule,
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }