Skip to content

Instantly share code, notes, and snippets.

@pravnkay
Created December 16, 2019 14:50
Show Gist options
  • Save pravnkay/0dd0221ca3292f6d65f38f8868fb9b8f to your computer and use it in GitHub Desktop.
Save pravnkay/0dd0221ca3292f6d65f38f8868fb9b8f to your computer and use it in GitHub Desktop.
SweetAlert2 for VueJS

SweetAlert2 integration to VueJS

There are too many wrappers for sweetalert2 for vuejs and most of them does the same thing with less functionality.

Here is how to integrate the default SweetAlert package into VueJS

Step 1

Install SweetAlert2

npm install sweetalert2

Step 2

Insert in script section of whichever component you want to use

import Swal from 'sweetalert2'

created: function() {
 Swal.fire({
	 toast: true,
	 position: 'top-end',
	 showConfirmButton: true,
	 confirmButtonText: 'Okay',
	 icon: 'success',
	 title: 'SweetAlert is Working'
 })
}

All this is from default documentation of SweetAlert2.

No wrapper needed

Will update this gist with various examples
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment