我目前正在使用sweetalert2,我正在尝试检测警报何时关闭。但是,DeleteUnsavedImages函数未触发。我认为将函数分配给onclose键会起作用,但没有运气。
swal({
html: data,
showCloseButton: false,
showCancelButton: false,
width: 800,
showConfirmButton: false,
onClose: DeleteUnsavedImages()
}).then(function () {
});
function DeleteUnsavedImages(){
var test = "-1";
}
任何帮助,将不胜感激 :-)
我用我的甜蜜警报进行测试以确认问题,你只需要传递没有()
的函数名称,函数将在swal的onClose
事件处理程序中调用。当onClose
被解雇时,它被称为传递函数的引用。
像这样做一点改变:
swal({
html: data,
showCloseButton: false,
showCancelButton: false,
width: 800,
showConfirmButton: false,
onClose: DeleteUnsavedImages // Removed () from here
}).then(function () {
});
function DeleteUnsavedImages(){
var test = "-1";
}
swal({
html: data,
showCloseButton: false,
showCancelButton: false,
width: 800,
showConfirmButton: false,
onClose: () => {
DeleteUnsavedImages();
}
})