zoukankan      html  css  js  c++  java
  • 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() 就可以关闭

  • 相关阅读:
    [LUOGU] 1364 医院设置
    [POJ] 3278 Catch That Cow
    [OpenJudge] 2727 仙岛寻药
    [POJ] 2386 Lake Counting
    [POJ]1118 Lining up
    [LUOGU]1141 01迷宫
    [POJ]1111 Image Perimeters
    python之路——初识函数
    python----------文件操作
    Python中的split()函数的用法
  • 原文地址:https://www.cnblogs.com/telwanggs/p/7513529.html
Copyright © 2011-2022 走看看