Flutter教程

ion-alert-controller

概要(CONTENTS)

Ionic4项目中我们可以使用Ionic4弹窗组件ion-alert-controller对项目进行布局。

ion-alert-controller官方文档地址:https://ionicframework.com/docs/api/alert-controller

Alert controllers programmatically control the alert component. Alerts can be created and dismissed from the alert controller. View the Alert documentation for a full list of options to pass upon creation.

async function presentAlert() {
  const alertController = document.querySelector('ion-alert-controller');
  await alertController.componentOnReady();

  const alert = await alertController.create({
    header: 'Alert',
    subHeader: 'Subtitle',
    message: 'This is an alert message.',
    buttons: ['OK']
  });
  return await alert.present();
}

ion-alert-controller 内置方法(Methods)

create

Description

Create an alert overlay with alert options.

Signature create(options: AlertOptions) => Promise

dismiss

Description

Dismiss the open alert overlay.

Signature dismiss(data?: any, role?: string | undefined, id?: string | undefined) => Promise

getTop

Description

Get the most recently opened alert overlay.

Signature getTop() => Promise