sweetalert 是一个 可以用来替换JavaScript“Alert”的漂亮的控件,用起来简单,而且有丰富的形式,在交互的过程中,用上sweetalert 会使你的交互模式提高一个 档次。
![]() |
---|
(下载的附件中附有DEMO)
1. 引入文件
< script src = " https://unpkg.com/sweetalert/dist/sweetalert.min.js " > < / script >
//错误提示
swal("Oops!", "Something went wrong!", "error");
//带有附加到确认消息的功能
swal({
title: "Are you sure?",
text: "Are you sure that you want to leave this page?",
icon: "warning",
dangerMode: true,
})
.then(willDelete => {
if (willDelete) {
swal("Deleted!", "Your imaginary file has been deleted!", "success");
}
});
//使用异步/等待
const willDelete = await swal({
title: "Are you sure?",
text: "Are you sure that you want to delete this file?",
icon: "warning",
dangerMode: true,
});
if (willDelete) {
swal("Deleted!", "Your imaginary file has been deleted!", "success");
}
GitHub 地址 :https://gitcode.net/mirrors/t4t5/sweetalert?utm_source=csdn_github_accelerator