SweetAlert: Unexpected 2nd argument (function(){})

本文共有382个字,关键词:

问题:使用sweetalert时报错:uncaught exception: SweetAlert: Unexpected 2nd argument (function(){})
解决:这是因为sweetalert2.0和1.0不同,function是1.0中的,2.0中可以使用then
方法:

swal({
title: '提示',
text: '2秒后将自动关闭',
timer: 2000,
buttons: false,
closeOnClickOutside: false,
})
.then(() => {
return $.post('/',{'sid': {{ sid }}});
})
.then(data => {
swal('成功');
})
.catch(err => {
swal('111');
});

版权声明:本文为作者原创,如需转载须联系作者本人同意,未经作者本人同意不得擅自转载。
添加新评论
暂无评论