Swal not defined laravel
error 'Swal' is not defined no-undef
import swal from 'sweetalert2';
window.Swal = swal;
Is defined but doesn`t work
alertDelete() {
Swal.fire({
title: 'You can`t delete this',
text: "You can`t do this",
icon: 'warning',
showCancelButton: true,
confirmButtonText: 'Yes!',
})
},
@kikogyh
add the CDN links in the head section
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/6.6.9/sweetalert2.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/6.6.9/sweetalert2.min.js"></script>
@section('scripts')
@if (alert()->ready())
<script>
swal({
title: "{!! alert()->message() !!}"
});
</script>
@endif
@endsection
but the specification is PHP Version: 7.1.9
Try this
@kikogyh
import swal from 'sweetalert2';
window.swal = swal
or
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@8"></script>
Thank You. Your second answer helps me
Where is this function?
alertDelete() {
Swal.fire({
title: 'You can`t delete this',
text: "You can`t do this",
icon: 'warning',
showCancelButton: true,
confirmButtonText: 'Yes!',
})
},
Make sure it is run after your app.js file where you attach Swal to window
i so
I solved it, I had to use window.swal.fire in vue file
I installed it today to my Project. I had to use the "new" keyword, because it creates a new instance of Swal.
new Swal({...}), with it it's working for me.
Please or to participate in this conversation.