function confirmation() {
swal.fire({
title: "Are you sure?",
text: "Your about to delete some files",
type: "warning",
showCancelButton: true,
showConfirmButton: true,
confirmButtonText: 'Yes, I am sure!',
cancelButtonText: "No, cancel it!",
closeOnConfirm: false,
closeOnCancel: false
}).then((result) => {
if (result.isConfirmed) {
swal.fire("Deleted!", "files are successfully deleted!", "success");
} else {
window.location = "....";
}
});
}
但即使我确认或否认它只是取消了我能做什么?我也试着用 isDenied
还是什么都没有。
1条答案
按热度按时间bcs8qyzn1#
对于sweetalert中的取消按钮,您应该使用
.isDismissed()
sweeetalertresult对象的方法。您还使用了不推荐使用的属性(CloseOnConfig、closeoncancel、type):jsfiddle:https://jsfiddle.net/sdurwc9y/
单击“取消”按钮等同于在警报窗口外单击。所以你可以用
else
而不是if (result.isDismissed)
.