【发布时间】:2021-06-28 19:14:12
【问题描述】:
我的 Ionic 5 和 Angular 应用程序有一个小问题。
所以在这里,我有一个离子段,但我无法更改处于活动/选中状态的段按钮的背景颜色。
除了官方文档之外,我尝试了许多在论坛上阅读的不同方法,但仍然是不可能的。
你能帮帮我吗?
我 home.html 中的离子段:
<ion-segment value='favorites' [(ngModel)]="segmentModel" (ionChange)="segmentChanged($event)" color="maindark" mode='ios' swipeGesture='true' scrollable='true'>
<ion-segment-button value="favorites">
<ion-label>Favoris</ion-label>
</ion-segment-button>
<ion-segment-button value="settings">
<ion-label>Paramètres</ion-label>
</ion-segment-button>
</ion-segment>
home.scss 中段的 SCSS :
ion-segment {
padding: 5px 0 5px 0;
margin: 5vh 15vw 0 15vw;
background-color: #2d303aab;
}
ion-segment-button {
padding: 7px 0 7px 0;
font-size: 16px;
color: white;
}
.segment-button-checked {
color: #F8CF80 !important; // it works properly
// Tried all of that but nothing work
background-color: #2D303A !important;
background: #2D303A !important;
--background: #2D303A !important;
--background-color: #2D303A !important;
--background-checked: #2D303A !important;
}
【问题讨论】:
-
你想给按钮上色吗?抱歉,我对实际需要什么有点困惑。你能做一个stackblitz,这样我们就可以看到代码了。
标签: angular ionic-framework properties version-control segment