阻止 SweetAlert2 来自 closing/dismissing 的 willClose?
Prevent SweetAlert2 from closing/dismissing from willClose?
抱歉,如果我遗漏了文档中的某些内容,但无论如何我都找不到阻止对话框在 SweetAlert 2 中关闭的方法,这些方法将不起作用:
await Swal.fire({
html: diagHtml,
showCancelButton: true,
willClose: (el) => {
console.log(el);
if (someLogic()) {
event.preventDefault();
return false;
}
},
});
有没有办法让对话保持不变,最好是 async
?
不,您不能使用 willClose 阻止对话框关闭,也许下面的代码可以替代您:
await Swal.fire({
html: diagHtml,
showDenyButton: true,
allowOutsideClick: false,
allowEscapeKey: false,
preConfirm: () => {
if (someLogic()) {
return false; // Prevent confirmed
}
},
preDeny: () => {
if (someLogic()) {
return false; // Prevent denied
}
},
});
抱歉,如果我遗漏了文档中的某些内容,但无论如何我都找不到阻止对话框在 SweetAlert 2 中关闭的方法,这些方法将不起作用:
await Swal.fire({
html: diagHtml,
showCancelButton: true,
willClose: (el) => {
console.log(el);
if (someLogic()) {
event.preventDefault();
return false;
}
},
});
有没有办法让对话保持不变,最好是 async
?
不,您不能使用 willClose 阻止对话框关闭,也许下面的代码可以替代您:
await Swal.fire({
html: diagHtml,
showDenyButton: true,
allowOutsideClick: false,
allowEscapeKey: false,
preConfirm: () => {
if (someLogic()) {
return false; // Prevent confirmed
}
},
preDeny: () => {
if (someLogic()) {
return false; // Prevent denied
}
},
});