作者:看是语言_263 | 来源:互联网 | 2022-10-29 13:56
我想在ionic 4中提供警报控制器样式,这是我的演示代码,
async presentalert() {
const alert = await this.alertCtrl.create({
header: ' DO YOU WANT TO CANCEL',
message: 'DO YOU WANT TO CANCEL',
cssClass: 'alertCancel',
mode: 'ios',
buttons: [
{
text: 'NO',
role: 'cancel',
cssClass: 'alertButton',
handler: () => {
console.log('Confirm Cancel');
}
}, {
text: 'YES',
cssClass: 'alertButton',
handler: () => {
console.log('Confirm Okay');
}
}
]
})
await alert.present();
}
我试图在global.scss中应用scss
.alertCancel{
--background: red;
}
.alertButton {
background-color: white !important;
}
我已经尝试了所有可能的方法来在警报控制器中提供CSS,但是它无法正常工作,因此请帮助我,我被困在这里。
1> Peter Haddad..:
--background
is a css variable of the component ion-alert
, therefore do the following in the variables.scss
ion-alert
{
--background: red !important;
}
For reference:
https://ionicframework.com/docs/theming/css-variables#ionic-variables
https://petercoding.com/2019/04/25/theming-your-app-in-ionic4/#css-custom-properties