ionic3 Alerts

2020-03-31  本文已影响0人  谢耳朵六六六
import { AlertController } from 'ionic-angular';

export class MyPage {

  constructor(public alertCtrl: AlertController) { }

  showAlert() {
    const alert = this.alertCtrl.create({
      title: 'alert的标题。',
      subTitle: 'alert的副标题。',
      enableBackdropDismiss: false,  //是否可以通过点击背景来关闭alert.
      buttons: [
        {
          text: 'Cancel',
          //    按下按钮时触发的逻辑。
          handler: data => {
            console.log('Cancel clicked');
          }
        },
        {
          text: 'Save',
          handler: data => {
            console.log('Saved clicked');
          }
        }
      ]
    });
    alert.present();
  }
}
上一篇 下一篇

猜你喜欢

热点阅读