我不确定是否发现错误或配置是否关闭。我的其他组件呈现并看起来像它们应该的那样。但是材质角的按钮样式加载不正确。
我使用的是有角度的,问题出在这里https://material.angular.io/components/button/overview
的凸起按钮上这是我的标记
<div class="nav-item">
<button class="mat-raised-button"
(click)="navToCreate()">
New Post
</button>
</div>
<div class="nav-item">
<button class="mat-raised-button" *ngIf="isLoggedIn === false" (click)="navToLogin()">
<i class="material-icons md-48">account_box</i>
<span>Login</span>
</button>
</div>
<div class="nav-item">
<button class="mat-raised-button" *ngIf="isLoggedIn === true" (click)="logOut()">
<i class="material-icons md-48">account_box</i>
<span>Logout</span>
</button>
</div>
这就是他们渲染成的 Pic of buttons
我的app.module是以下
import { BrowserModule } from '@angular/platform-browser';
import { HttpClientModule } from '@angular/common/http';
import { NgModule } from '@angular/core';
import { ReactiveFormsModule } from '@angular/forms';
import { FormsModule } from '@angular/forms';
import { AppRoutingModule } from './app-routing.module';
// Material components
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { MatCardModule } from '@angular/material/card';
import { MatSnackBarModule } from '@angular/material/snack-bar';
import { MatSidenavModule } from '@angular/material/sidenav';
import { MatToolbarModule } from '@angular/material/toolbar';
import { MatTabsModule } from '@angular/material/tabs';
import { MatListModule } from '@angular/material/list';
import { MatButtonModule } from '@angular/material/button';
// Components
import { AppComponent } from './app.component';
import { HomeComponent } from './components/home/home.component';
import { DiscussionCardComponent } from './components/discussion-card/discussion-card.component';
import { LoginComponent } from './components/login/login.component';
import { DiscussionDetailComponent } from './components/discussion-detail/discussion-detail.component';
import { SideMenuComponent } from './components/side-menu/side-menu.component';
import { DiscussionCreateComponent } from './components/discussion-create/discussion-create.component';
import { DiscussionDetailPageComponent } from './components/discussion-detail-page/discussion-detail-page.component';
import { TruncatePipe } from './pipes/truncate.pipe';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
@NgModule({
declarations: [
AppComponent,
HomeComponent,
DiscussionCardComponent,
LoginComponent,
DiscussionDetailComponent,
TruncatePipe,
SideMenuComponent,
DiscussionCreateComponent,
DiscussionDetailPageComponent,
],
imports: [
BrowserModule,
HttpClientModule,
AppRoutingModule,
ReactiveFormsModule,
FormsModule,
BrowserAnimationsModule,
MatFormFieldModule,
MatInputModule,
MatCardModule,
MatSnackBarModule,
MatSidenavModule,
MatToolbarModule,
MatTabsModule,
MatListModule,
MatButtonModule,
],
exports: [],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
感谢您的帮助。谢谢
答案 0 :(得分:0)
您的错误是mat-raised-button
部分。它不是类,而是按钮的属性。
<button mat-raised-button>
是正确的,<button class="mat-raised-button">
使用的是课程