如何在 mat-datepicker 中隐藏 header 的年份切换

How to hide year toggle from header in mat-datepicker

.mat-calendar-period-button{
min-width: 0;
display: none !important; 
}

button.mat-calendar-period-button.mat-button.mat-button-base {
display: none !important;
}

button:not(:disabled), [type="button"]:not(:disabled), [type="reset"]:not(:disabled),  
[type="submit"]:not(:disabled) {
cursor: pointer;
display: none !important;
}

我用过这个CSS但是没用。

如果您有标准 ViewEncapsulation, you need to add ::ng-deep 到您正在使用的组件内部的样式。试试这个:

:host ::ng-deep .mat-calendar-period-button{
  display: none; 
}