![](/img/trans.png)
[英]trying to implement a side navigation with a toggle button in <mat-toolbar>?
[英]“Color” attribute does not work on <mat-toolbar> in a side navigation in Angular Materia
我無法讓mat-toolbar
根據我的主題改變顏色。 請看我的代碼:
HTML
<mat-sidenav #drawer class="sidenav" fixedInViewport
[attr.role]="(isHandset$ | async) ? 'dialog' : 'navigation'"
[mode]="(isHandset$ | async) ? 'over' : 'side'"
[opened]="(isHandset$ | async) === false">
<mat-toolbar color="primary" >Menu</mat-toolbar>
<mat-nav-list>
<a mat-list-item href="#">
<mat-icon aria-hidden="false" aria-label="Health Check" color="primary">poll</mat-icon>
Poll
</a>
<a mat-list-item href="#">
<mat-icon aria-hidden="false" aria-label="Health Check" color="primary">info</mat-icon>
Announcements
</a>
</mat-nav-list>
</mat-sidenav>
但在內容上,我沒有任何問題。 請看我的代碼。
<mat-sidenav-content>
<mat-toolbar color="primary">
<button
type="button"
aria-label="Toggle sidenav"
mat-icon-button
(click)="drawer.toggle()"
*ngIf="isHandset$ | async">
<mat-icon aria-label="Side nav toggle icon">menu</mat-icon>
</button>
<a mat-button href="#">
<mat-icon aria-hidden="false" aria-label="Health Check">accessibility_new</mat-icon>
Health Check
</a>
<span class="spacer"></span>
<div *ngIf="!isXs">
<a mat-button href="#">
<mat-icon aria-hidden="false" aria-label="Health Check">poll</mat-icon>
Poll
</a>
<a mat-button href="#">
<mat-icon aria-hidden="false" aria-label="Health Check">info</mat-icon>
Announcements
</a>
</div>
</mat-toolbar>
<!-- Add Content Here -->
<ng-content></ng-content>
</mat-sidenav-content>
在 mat-nav 組件中需要將 css 從:
.sidenav .mat-toolbar {
background: inherit;
}
至
.sidenav {
background: inherit;
}
當 mat-nav 組件由原理圖創建時會出現此問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.