SweetAlert如何實現點擊Confirm之后自動關閉


        swal({
          title: "Are you sure?",
          text: "You will not be able to recover this imaginary file!",
          type: "warning",
          showCancelButton: true,
          confirmButtonColor: "#DD6B55",
          confirmButtonText: "Yes, delete it!",
          cancelButtonText: "No, cancel plx!",
          closeOnConfirm: false,
          closeOnCancel: false
        },
        function(isConfirm){
          if (isConfirm) {
            swal({
              title: "Auto close alert!",
              text: "I will close in 2 seconds.",
              timer: 0,
              showConfirmButton: false
            });
            alert('asd');
          } else {
            swal("Cancelled", "Your imaginary file is safe :)", "error");
          }
        });

像這段代碼,可以實現點擊Confirm彈出一個新的SweetAlert框,原來的框會自動關閉,但是當我把function中的代碼改成alert('hello')之后,沒有調用swal方法,那么雖然alert可以正常執行,但是原來的框就不能自動關閉了。所以想請問下有沒有什么方法可以在回調函數中使用自定義方法,但是又能夠自動關閉原來的swal彈框。卡很久了,望大家賜教。

執行swal.close() 就可以關閉


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM