Javascript 我可以有多个Sweet Alert 2弹出窗口吗?

Javascript 我可以有多个Sweet Alert 2弹出窗口吗?,javascript,html,modal-dialog,alert,sweetalert2,Javascript,Html,Modal Dialog,Alert,Sweetalert2,我的HTML/Javascript应用程序使用我使用sweet Alert 2创建的模式弹出窗口。我们将其称为“警报1” Alert1使用自定义HTML,HTML中有一个按钮,我想触发另一个sweet alert 2模式弹出窗口,我们称之为“Alert2” Alert2有两个选项。“确认”或“取消”如果用户单击“取消”,我想返回警报1 注意:Alert1的自定义HTML是可编辑的,因此,我不能重新调用最初启动警报的代码,因为这将显示旧的HTML 这就是我尝试过的: function clickB

我的HTML/Javascript应用程序使用我使用sweet Alert 2创建的模式弹出窗口。我们将其称为“警报1”

Alert1使用自定义HTML,HTML中有一个按钮,我想触发另一个sweet alert 2模式弹出窗口,我们称之为“Alert2”

Alert2有两个选项。“确认”或“取消”如果用户单击“取消”,我想返回警报1

注意:Alert1的自定义HTML是可编辑的,因此,我不能重新调用最初启动警报的代码,因为这将显示旧的HTML

这就是我尝试过的:

function clickButton(){ //This function will be attached to the button in Alert1
    var currentSwal = document.getElementById('swal2-content').innerHTML;
      swal({
      title: "Confirm 'Remove Script Page'",
      text:
        "Are you sure you want to remove this page from the script?",
      type: "warning",
      showConfirmButton: true,
      showCancelButton: true
    }).then(function(dismiss) {
      if (dismiss.dismiss == "cancel" || dismiss.dismiss == 'overlay') {
        swal.close;
        swal({
          html: currentSwal,
          showConfirmButton: false,
          customClass: 'swal-extra-wide',
          showCloseButton: true
        });
      } //end if
      else {
      //go ahead and delete the script page
      } //end else
    });
}//end function
我的上述解决方案不起作用。这有点难以解释,但基本上,HTML代码被破坏了,事情就是不能正常工作

TLDR/我的问题:有没有办法获得多个SweetAlert2警报?(即从alert1启动alert2,然后关闭alert2,将视图返回到alert1?

是的,您可以

var modals = [];


  modals.push({title: 'title Of Modal1', text: 'text1' });

  modals.push({title: 'title Of Modal2', text: 'text2' });

swal.queue(modals);
参考资料

我不完全确定您想要做什么,但您是否尝试过使用swal2队列?您可以在上找到有关队列的更多信息。您想要的是所谓的“堆叠”模态。我还没有找到使用SweetAlerts2解决此问题的方法。