单击取消按钮时 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,此时垂直滚动条被禁用,到现在没问题。
在这种情况下用户有两种选择:
- 点击按钮 "Yes, delete it!" : 甜蜜警报消失,我的垂直滚动条返回。
- 点击按钮 "Cancel" :
所以甜蜜的警报消失了,但我的问题是我的垂直滚动条仍然禁用的事实,不应该是这种情况!
一个可能的解决方案 是在我的 <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
});
我在我的项目中使用 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,此时垂直滚动条被禁用,到现在没问题。
在这种情况下用户有两种选择:
- 点击按钮 "Yes, delete it!" : 甜蜜警报消失,我的垂直滚动条返回。
- 点击按钮 "Cancel" : 所以甜蜜的警报消失了,但我的问题是我的垂直滚动条仍然禁用的事实,不应该是这种情况!
一个可能的解决方案 是在我的 <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
});