我使用 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。
关于javascript - 如何在 SweetAlert 弹出窗口中添加关闭按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46447402/