简体   繁体   English

角度材质按钮与主题不匹配

[英]Angular Material Buttons not matching theme

I just have installed Angular 10 with Angular Materials ng add @angular/material我刚刚安装了带有 Angular Materials 的 Angular 10 ng add @angular/material

There I choose the custom theme: Purple/Green在那里我选择自定义主题:紫色/绿色

Next step was to simply add a Toolbar, basically copy paste from googles site.下一步是简单地添加一个工具栏,基本上是从谷歌网站复制粘贴。 But I cannot arrange the buttons matching the theme.但是我无法安排与主题匹配的按钮。 I have no idea why it looks like this.我不知道为什么它看起来像这样。

在此处输入图片说明

how it should look它应该看起来如何

在此处输入图片说明

<mat-toolbar color="primary">
  <button mat-icon-button aria-label="Example icon-button with menu icon">
    <mat-icon>menu</mat-icon>
  </button>
  <span>My App</span>
  <span class="nav-spacer"></span>
  <button mat-icon-button class="material-icons-outlined" aria-label="Example icon-button with heart icon">
    <mat-icon>favorite</mat-icon>
  </button>
  <button mat-icon-button class="example-icon" aria-label="Example icon-button with share icon">
    <mat-icon>share</mat-icon>
  </button>
</mat-toolbar>

my stlye.css我的 stlye.css

/* You can add global styles to this file, and also import other style files */

html, body { height: 100%; }
body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; }

my index.html我的 index.html

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Frontend</title>
  <base href="/">
  <meta content="width=device-width, initial-scale=1" name="viewport">
  <link href="favicon.ico" rel="icon" type="image/x-icon">
  <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500&display=swap" rel="stylesheet">
  <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body class="mat-typography">
<app-root></app-root>
</body>
</html>

and these imports而这些进口

  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    AppRoutingModule,
    FormsModule,
    MatToolbarModule,
    MatIconModule,
  ],

What do I miss here please?请问我在这里想念什么?

您需要在导入中添加 MatButtonModule。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM