【发布时间】:2022-04-06 03:24:53
【问题描述】:
我正在尝试像确认按钮一样更改取消按钮的颜色,但由于某种原因它似乎不起作用。
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
cancelButtonColor: "#DD6B55",
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
cancelButtonText: "No, cancel please!",
closeOnConfirm: false,
closeOnCancel: false
}, function (isConfirm) {
if (isConfirm) {
swal("Deleted!", "Your imaginary file has been deleted.", "success");
} else {
swal("Cancelled", "Your imaginary file is safe :)", "error");
}
});
【问题讨论】:
-
cancelButtonColor不是the API 中的选项 -
我在文档中没有看到该选项。也许那里不支持。您始终可以使用 CSS 创建自己的类。
-
试试这个.... jsfiddle.net/x20ra1o1/2
-
感谢哈克曼。它奏效了
标签: javascript sweetalert