Mic*_*ick 2 jquery sweetalert sweetalert2
我在这里做错了什么?
swal({
title: "Done.",
text: "Labels Printed.",
timer: 1000,
type: "success",
showConfirmButton: false
}).then(function () {
alert('done');
});
Run Code Online (Sandbox Code Playgroud)
警报未触发,我是否需要以某种方式捕获“计时器”?(警报只是一个示例,我实际上是在这里清除表单。)
另外,我该如何摆脱textLabels:1未捕获(承诺)计时器错误?
我在用 .done()
有人可以为SweetAlert2添加标签吗?我没有做到这一点的声誉。
米克
如果我不希望以后发生任何事情,该怎么办?:
swal({
title: "Error.",
text: "Authorisation Failed.",
timer: 1000,
type: "error",
showConfirmButton: false
}).then(
function() {}
)
Run Code Online (Sandbox Code Playgroud)
像这样?:
}).then(
function() {},
function() {}
)
Run Code Online (Sandbox Code Playgroud)
更新(17.11.2017):
从v7.0.0开始,SweetAlert2的工作原理与问题入门者所期望的完全相同:)
SweetAlert2使用承诺。每个承诺都可以解决或拒绝,您可以通过以下方式进行处理:
swal(…).then(
function () {
// handle resolve (confirm button)
},
function (dismiss) {
// handle reject, dismiss can be 'cancel', 'overlay', 'close', and 'timer'
}
)
Run Code Online (Sandbox Code Playgroud)
通过计时器关闭模态被视为承诺拒绝,因此您应按以下方式处理:
swal(…).then(
function () {
// handle resolve (confirm button)
},
function (dismiss) {
// handle reject, dismiss can be 'cancel', 'overlay', 'close', and 'timer'
}
)
Run Code Online (Sandbox Code Playgroud)
swal({
title: 'Auto close alert!',
text: 'I will close in 2 seconds.',
timer: 2000
}).then(function() {
alert('done');
})
Run Code Online (Sandbox Code Playgroud)