当我单击 Sweetalert2 中的“取消”按钮时会显示此错误
swal({
title: menu_title,
text: title,
input: "text",
showCancelButton: true,
animation: "slide-from-top",
showLoaderOnConfirm: true,
inputPlaceholder: lang.write_your_comment,
preConfirm: function(inputValue) {
return new Promise(function(resolve, reject) {
resolve('ok');
});
})
},
allowOutsideClick: false
}).then(function(result){
var res = $.parseJSON(result);
if(res.status){
swal({
title: lang.thankyou+"!",
text: lang.your_feedback_sent,
type: "success"
}).then(function(confirm){
location.reload();
});
} else{
swal({
title: lang.sorry+"!",
text: res.message,
type: "warning"
});
}
});
当点击关闭图标时,它也显示错误,
未捕获的异常:关闭
应该张贴在这里: https :
如果有人来到这里并被卡住(因为sweetalert != sweetalert2
!)
在swal({...})
的末尾,添加: .catch(() => swal.close())
每个承诺函数都需要一个失败回调。
@eminx你救了我的一天 :)
@eminx我也是!!
最有用的评论
如果有人来到这里并被卡住(因为
sweetalert != sweetalert2
!)在
swal({...})
的末尾,添加:.catch(() => swal.close())
每个承诺函数都需要一个失败回调。