SweetAlert2-强大的纯Js模态消息对话框插件 A beautiful and customizable replacement for JavaScript's popup boxes

SweetAlert2

下面是一个默认的浏览器弹出对话框和SweetAlert2对话框的比较效果。

浏览器内置的对话框

Code:
alert('Oops! Something went wrong!')

SweetAlert2

Code:
sweetAlert(
  'Oops...',
  'Something went wrong!',
  'error'
)

Pretty cool huh? SweetAlert2 automatically centers itself on the page and looks great no matter if you're using a desktop computer, mobile or tablet. It's even highly customizeable, as you can see below!

More examples

In these examples, we're using the shorthand function swal.

Modal Types

Input Types

Multiple inputs aren't supported, you can achieve them by using html and preConfirm parameters.
Notice that in preConfirm function you can pass the custom result to resolve():