【发布时间】:2020-07-05 09:13:21
【问题描述】:
我正在使用 angular 8.0.0、angular material 和 Fuse Theme as admin panel。
问题是,每当我更改 mat-select 的样式时,它就会被应用,但经过一两次刷新后,角度材质会覆盖本地组件更改并应用默认值。
它也适用于所有组件我怎样才能改变只有一个 mat-select 的样式?
我的 html 的一部分是问题所在:
<form>
<mat-form-field>
<mat-label class="label-colors"> bla bla </mat-label>
<mat-select formControlName="">
<mat-option value="active" class="empty-select">bla bla</mat-option>
<mat-option value="inactive" >bla bla</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field>
<mat-label class="label-colors"></mat-label>
<mat-select formControlName="isReserved">
<mat-option value="active"></mat-option>
<mat-option value="inactive"></mat-option>
</mat-select>
</mat-form-field>
</form>
scss 文件:
.mat-select-arrow{
color: rgba(255, 255, 255, 0.54)!important;
}
.label-colors {
color: #ffffff !important;
font-size: 16px;
}
// mat-input caret color
.input-element-color {
caret-color: #ffffff !important;
}
.blue{
background-color: blue;
}
.mat-form-field-underline{
background-color: rgb(61, 82, 89)!important;
}
.date-icons{
color: #ffffff !important;
width: 100%;
height: 100%;
}
th{
font-weight: bold !important ;
color:black !important;
font-size: 14px !important;
}
// .mat-select-value-text{
// color: #fff!important;
// }
.mat-form-field{
//width: 155px;
margin: 3px;
}
// body.theme-default .mat-select-value{
// color: rgba(255, 255, 255, 0.87);
// }
.editdeleteicon{
color: #003042;
}
.fix-text{
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 88px;
padding: 0 10px !important;
}
.fix-text :hover{
overflow: visible;
}
尝试了有关 stackoverflow 的所有建议,但似乎无法更改 mat-select 的颜色并保持这种状态,即使我可以,但当我更改时,它确实会在其他任何地方发生变化。我希望我清楚
更新:通过添加类 mat-form-field 然后在 scss 中修复
.example-class{
// inside this class added:
.mat-select-value-text {
color: red;
}
}
【问题讨论】: