SweetAlert showLoaderOnConfirm 不显示

MrR*_*bot 1 javascript sweetalert

我正在使用 sweetalert 来显示删除确认,并稍后在加载操作中显示时对其进行处理,虽然它不起作用,但这是代码,不起作用(它应该显示加载动画,但实际上不是这样做)有什么想法吗?

这是 JavaScript

document.querySelector('div.test').onclick = function() {
swal({
title: 'Ajax request example',
text: 'Submit to run ajax request',
type: 'info',
showCancelButton: true,
closeOnConfirm: false,
showLoaderOnConfirm: true,
}, function(){
 setTimeout(function() {
  swal('Ajax request finished!');
}, 2000);
});
};
Run Code Online (Sandbox Code Playgroud)

网页

<div class="test">
<button>show alert</button>
 </div>
Run Code Online (Sandbox Code Playgroud)

这是小提琴

Lim*_*nte 5

Sweetalert 不再受支持。您可能想切换到sweetalert2

Swal.fire({
  title: 'Ajax request example',
  text: 'Submit to run ajax request',
  icon: 'info',
  showCancelButton: true,
  showLoaderOnConfirm: true,
  preConfirm: function() {
    return new Promise(function(resolve, reject) {
      // here should be AJAX request
      setTimeout(function() {
        resolve();
      }, 1000);
    });
  },
}).then(function() {
  Swal.fire('Ajax request finished!');
});
Run Code Online (Sandbox Code Playgroud)
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
Run Code Online (Sandbox Code Playgroud)