Angular Ionic4-如何在中心对齐警报接口?

Angular Ionic4-如何在中心对齐警报接口?,angular,ionic-framework,ionic4,Angular,Ionic Framework,Ionic4,只是一个快速修复,但如何使我的按钮居中?我正在使用“alertCtrl.create” 此外,在alert-ionic docs页面中似乎没有某种居中 使用mode md to ios,因为默认情况下,`mode='ios'按钮位于中间 alertCtrl.create ({ header: 'Invalid Input', mode:'ios', //by default you will get the button in center message: 'P

只是一个快速修复,但如何使我的按钮居中?我正在使用“alertCtrl.create”

此外,在alert-ionic docs页面中似乎没有某种居中


使用mode md to ios,因为默认情况下,`mode='ios'按钮位于中间

alertCtrl.create ({  
    header: 'Invalid Input',
    mode:'ios', //by default you will get the button in center
    message: 'Please enter correct details',
    buttons: ['Okay']
}).then(alertElement => alertElement.present());
    return;
}

您还可以使用css自定义类将按钮居中。当我尝试
模式:“ios”
时,它改变了Android的本机外观,并显示为ios

创建警报时,添加css类属性:

alertCtrl.create ({  
    cssClass: 'my-alert', // Custom css class
    header: 'Invalid Input',
    message: 'Please enter correct details',
    buttons: ['Okay']
}).then(alertElement => alertElement.present());
    return;
}
并将
my alert
类添加到您的
global.scss

.my-alert .alert-wrapper {      
    .alert-button-group {
      justify-content: center;
    }
  }
.my-alert .alert-wrapper {      
    .alert-button-group {
      justify-content: center;
    }
  }