最佳确认对话框 JavaScript 库
Best confirm dialog JavaScript library
我想使用 确认对话框,它看起来比内置 JavaScript confirm()
方法生成的对话框更好。
我已尝试 Toastr,但发现 confirm
功能使用 No/Yes 按钮实现起来有点棘手。它仍然必须维护和更新。
感谢大家的建议!
尝试jquery-confirm。他们有各种各样的设计。
我认为最美丽的 API 之一是 SweetAlert2。
您可以按如下方式设置对话框:
swal({
title: 'Are you sure?',
text: "You won't be able to revert this!",
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!'
}).then((result) => {
if (result.value) {
swal(
'Deleted!',
'Your file has been deleted.',
'success'
)
}
})
这是它的样子:
您甚至可以自定义 CSS 以使其适应您的项目颜色。
希望对您有所帮助!
我想使用 确认对话框,它看起来比内置 JavaScript confirm()
方法生成的对话框更好。
我已尝试 Toastr,但发现 confirm
功能使用 No/Yes 按钮实现起来有点棘手。它仍然必须维护和更新。
感谢大家的建议!
尝试jquery-confirm。他们有各种各样的设计。
我认为最美丽的 API 之一是 SweetAlert2。
您可以按如下方式设置对话框:
swal({
title: 'Are you sure?',
text: "You won't be able to revert this!",
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!'
}).then((result) => {
if (result.value) {
swal(
'Deleted!',
'Your file has been deleted.',
'success'
)
}
})
这是它的样子:
您甚至可以自定义 CSS 以使其适应您的项目颜色。
希望对您有所帮助!