"swal is not defined" after migrating from Sweet Alert 1
See original GitHub issueI was previously using the original Sweet Alert, and things were working fine. Upgraded to SA2 and followed the migration guide. My code:
import swal from "sweetalert2"
swal({
title: "Are you sure?",
text: "This cannot be undone.",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes.",
closeOnConfirm: false,
showLoaderOnConfirm: true
}).then(function() {
/* do stuff */
})
This results in swal is not defined
.
Webpack doesn’t report an error, so it’s not a compilation issue. Do I have to do something else to make this work? Other than switching from callbacks to promises as per the migration guide, nothing else has changed in my code. Using Chrome.
Issue Analytics
- State:
- Created 6 years ago
- Comments:17 (7 by maintainers)
Top GitHub Comments
85reactions
limontecommented, Mar 29, 2017
34reactions
webhackingcommented, Feb 7, 2018
Top Results From Across the Web
Sweetalert SWAL is not defined - after NPM install - Laracasts
I have installed sweetalert by the following command: npm install sweetalert --save Now it appears if ... Sweetalert SWAL is not defined -...
Read more >ReferenceError: "Swal is not defined" - Stack Overflow
I'm working on small project using codeigniter and VueJs and sweet alert javascript library. but i get an error ...
Read more >SweetAlert2 (Swal is not defined) How to solve? - jQuery Forum
When I click the button, no action is taken. On the "Console" I get the following message: "Uncaught ReferenceError: Swal is not defined"....
Read more >Guides - SweetAlert
Showing an alert. After importing the files into your application, you can call the swal function (make sure it's called after the DOM...
Read more >[Solved]-ReferenceError: "Swal is not defined"-Vue.js
Swal (with Capital S) and Swal.fire() is introduced in sweetalert2 version > 7.20.0 . In older versions ( < 7.20.0 ), you should...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found