在 [filename.ts] 内的警报弹出窗口中添加下拉选择

Adding drop down selection in alert popup inside [filename.ts]

https://forum.ionicframework.com/t/popup-input/124197/2

大家好,我有一个问题。是否可以在此输入下方添加下拉选择?我为此搜索了很多次,但没有任何相关内容。我认为问题是我不知道要搜索什么。我需要你们帮我解决这个问题。感谢您以后的回答。

import { AlertController } from 'ionic-angular';

constructor(private alertCtrl: AlertController) {

}

presentPrompt() {
  let alert = this.alertCtrl.create({
    title: 'Login',
    inputs: [
      {
        name: 'username',
        placeholder: 'Username'
      },
      {
        name: 'password',
        placeholder: 'Password',
        type: 'password'
      }
    ],

  });
  alert.present();
}

正如文档所说 ion-alert:

Alerts can also include several different inputs whose data can be passed back to the app. Inputs can be used as a simple way to prompt users for information. Radios, checkboxes and text inputs are all accepted, but they cannot be mixed.

看来您的通知中不能有下拉菜单 布局。如果你想要一个复杂的布局(例如布局中的下拉菜单),我建议你使用 popovermodal。我在下面的每个文档中都留下了 link:

ion-popover: https://ionicframework.com/docs/api/popover

ion-modal: https://ionicframework.com/docs/api/modal