Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery SweetAlert2定时器后执行功能_Jquery_Sweetalert_Sweetalert2 - Fatal编程技术网

Jquery SweetAlert2定时器后执行功能

Jquery SweetAlert2定时器后执行功能,jquery,sweetalert,sweetalert2,Jquery,Sweetalert,Sweetalert2,我做错了什么 swal({ title: "Done.", text: "Labels Printed.", timer: 1000, type: "success", showConfirmButton: false }).then(function () { alert('done'); }); 警报没有被触发,我是否需要以某种方式捕捉“计时器”?(警报只是一个例子,我实际上正在清除我的表单。) 另外,我如何消除textLabels:1

我做错了什么

swal({
    title: "Done.",
    text: "Labels Printed.",
    timer: 1000,
    type: "success",
    showConfirmButton: false

}).then(function () {

    alert('done');

});
警报没有被触发,我是否需要以某种方式捕捉“计时器”?(警报只是一个例子,我实际上正在清除我的表单。)

另外,我如何消除textLabels:1未捕获(承诺中)计时器错误

我正在使用
.done()

有人能为SweetAlert2添加标签吗?我没有做这件事的名声

米克

当我不希望以后发生任何事情时,我需要做什么

swal({
    title: "Error.",
    text: "Authorisation Failed.",
    timer: 1000,
    type: "error",
    showConfirmButton: false
}).then(
    function() {}

 )
像这样

}).then(
        function() {},
        function() {}
       )
更新(2017年11月17日):

从SweetAlert2开始工作与问题发起者所期望的完全一样:)


SweetAlert2使用承诺。每个承诺都可以解决拒绝,您可以这样处理:

swal(…).then(
  function () {
    // handle resolve (confirm button)
  }, 
  function (dismiss) {
    // handle reject, dismiss can be  'cancel', 'overlay', 'close', and 'timer'
  }
)
按计时器关闭模式被视为拒绝承诺,因此您应如下处理:
Swal.fire({
标题:“自动关闭警报!”,
文字:“我将在2秒钟后关闭。”,
计时器:2000
}).然后(函数(){
警报(“完成”);
})

太棒了,很管用。我发现这个例子令人困惑,并且没有意识到我需要函数(){}。甜心2号很棒。谢谢。很高兴我帮了你,谢谢你使用了甜食警报2!