如何更改 ion-select 的默认警报弹出窗口的样式?

How do I change the styling of the default Alert Popup of ion-select?

我想包括我在我正在开发的应用程序中使用的原色、二次色和三次色,但我还没有找到实现它的方法。但是在看了这里并试图在 google 上找到答案之后,但没有运气,所以我在这里问。

我试着查看官方文档,但没有找到任何与它使用的警报相关的内容。

<ion-select formControlName="currency">
  <ion-select-option value="btc" checked="true">Bitcoin</ion-select-option>
  <ion-select-option value="ethereum">Ethereum</ion-select-option>
</ion-select>

目前看起来像这样(我还不能 post 图片所以我必须直接包含 link)

https://i.imgur.com/aMGFhHZ.png

虽然离子颜色用于初级,二级和三级是这样使用的

https://i.imgur.com/TlUP79g.png

有没有办法在不创建自定义警报的情况下执行此操作?

在您的 .ts 文件中

 async presentAlert(){ 
    const alert = await this.alertController.create({
          header: "My Header",
          message:
            "this is my message.",
            cssClass: "CUSTOMCSS", <<<< place the class name there
          buttons: [
            {
              text: "Cancel",
              role: "cancel",
              cssClass: "secondary",
              handler: blah => {
                // Do something
              }
            },
            {
              text: "Sync",
              handler: () => {
                // Do something
              }
            }
          ]
        });
        await alert.present();
    }

然后在你的 global.scss

.CUSTOMCSS{
    *{
        ion-item {
           --background: var(--ion-color-primary);
           color: var(--ion-color-dark);
        }
    }
}