很抱歉,如果我在文档中遗漏了一些东西,但我找不到在SweetAlert 2中阻止对话框关闭的方法,这些方法将不起作用:
await Swal.fire({
html: diagHtml,
showCancelButton: true,
willClose: (el) => {
console.log(el);
if (someLogic()) {
event.preventDefault();
return false;
}
},
});
有没有办法保持对话停留,最好是使用async
发布于 2020-10-31 23:16:36
不,你不能阻止用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
}
},
});
https://stackoverflow.com/questions/64620928
复制相似问题