单击取消按钮时 ngSweetAlert 垂直滚动条消失

ngSweetAlert vertical scroll bar disappear when clicking on cancel button

我在我的项目中使用 ngSweetAlert

除了我添加 showCancelButton: true 属性.

外,它工作得很好

确实,例如:

SweetAlert.swal({
   title: "Are you sure?",
   text: "Your will not be able to recover this imaginary file!",
   type: "warning",
   showCancelButton: true,
   confirmButtonColor: "#DD6B55",
   confirmButtonText: "Yes, delete it!",
   closeOnConfirm: false}, 
function(){ 
   //do something if "Yes, delete it!" button is clicked
});

调用时出现甜蜜提示window,此时垂直滚动条被禁用,到现在没问题。

在这种情况下用户有两种选择:


一个可能的解决方案 是在我的 <body> html 标签上添加 overflow-y: auto; css 属性 但是问题是在显示甜蜜警报时垂直滚动条没有被禁用。 (这不是我想要的理想...)

有人遇到过这个问题吗?

我解决了我的问题,你只需要添加:

closeOnCancel: true

所以现在,它看起来像这样:

SweetAlert.swal({
   title: "Are you sure?",
   text: "Your will not be able to recover this imaginary file!",
   type: "warning",
   showCancelButton: true,
   confirmButtonColor: "#DD6B55",
   confirmButtonText: "Yes, delete it!",
   closeOnConfirm: false,
   closeOnCancel: true}, 
function(){ 
   //do something if "Yes, delete it!" button is clicked
});