停止 ActionSheet 在 Ionic 3 中关闭

Stop ActionSheet from closing in Ionic 3

我在 Ionic 3 中有一个 ActionSheet,最后一个按钮用于显示更多选项。单击该按钮时,应在 ActionSheet 上再添加 2 个按钮。问题是当我单击任何按钮时,ActionSheet 正在关闭。我找不到阻止它关闭的方法。 有什么方法可以阻止 ActionSheet 关闭吗?

  onMore(){
    let actionSheet = this.actionSheetCtrl.create({
      buttons: [
        {
          text: 'Option 1',
          handler: () => {
          }
        },
        {
          text: 'More',
          handler: () => {
            this.showMore(actionSheet);
          }
        }
      ]
    });

    actionSheet.present();
  }


  private showMore(actionSheet){

    actionSheet.addButton({
      text: 'Option 2',
      handler: () => {
      }
    });
  }

很简单。 只需将 return false 添加到您的处理程序中,如下所示。

    onMore(){
    let actionSheet = this.actionSheetCtrl.create({
      buttons: [
        {
          text: 'Option 1',
          handler: () => {
          }
        },
        {
          text: 'More',
          handler: () => {
            this.showMore(actionSheet);
            return false;
          }
        }
      ]
    });
    actionSheet.present();
  }

Stackblitz