SweetAlert2 介绍
SweetAlert2是一款功能强大的纯js模态消息对话框插件。SweetAlert2用于替代浏览器默认的弹出对话框,它提供各种参数和方法,支持嵌入图片,背景,html标签等,并提供5种内置的情景类,功能非常强大。
安装
npm install --save sweetalert2
使用
Swal.fire({
title: 'Are you sure?',
text: 'You will not be able to recover this imaginary file!',
type: 'warning',
showCancelButton: true,
confirmButtonText: 'Yes,delete it!',
cancelButtonText: 'No,keep it'
}).then((result) => {
if (result.value) {
Swal.fire(
'Deleted!',
'Your imaginary file has been deleted.',
'success'
)
// For more information about handling dismissals please visit
// https://sweetalert2.github.io/#handling-dismissals
} else if (result.dismiss === Swal.DismissReason.cancel) {
Swal.fire(
'Cancelled',
'Your imaginary file is safe :)',
'error'
)
}
})
网站地址:https://sweetalert2.github.io/
GitHub:https://github.com/sweetalert2/sweetalert2
网站描述:强大的纯Js模态消息对话框插件
SweetAlert2
官方网站:https://sweetalert2.github.io/
小编说
以上是编程之家为你收集整理的SweetAlert2全部内容。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。