如何在SweetAlert弹出窗口中添加关闭按钮
问题描述:
我已经使用SweetAlert库在我的应用程序中显示弹出窗口。这是我的代码如何在SweetAlert弹出窗口中添加关闭按钮
swal({
title: "Are you sure?",
text: "Test message?",
type: "info",
showCancelButton: true,
focusConfirm: false,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes",
cancelButtonText: "No"
}, function (isConfirm) {})
我需要在右上角添加一个关闭按钮。基于文档,关闭按钮仅适用于SweetAlert2库。
是否可以在SweetAlert1库中添加关闭按钮?
答
swal({
title: "Are you sure?",
text: "Test message?",
type: "info",
showCancelButton: true,
focusConfirm: false,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes",
cancelButtonText: "No",
showCloseButton: true,
只需添加showCloseButton: true
,这将显示在弹出的右上角的关闭X图标。
来源:参见SweetAlerts2 Docs
注“自定义HTML描述和按钮ARIA标签”例如,它是不是在SweetAlert1库现在已不建议使用,我建议使用SweetAlert2。
看来你使用AngularJS。为什么不使用** ngSweetAlert **? https://github.com/oitozero/ngSweetAlert – Zooly
我已经在我的应用程序中使用了sweetalert。我不能使用任何其他库 –
还有一个取消按钮,它也可以用来关闭弹出 –