'SweetAlert2 with Vue 3 and <script setup>

I have the Laravel/Inertia app and I use VueSweetAlert2 imported globally in app.js. It works well on every component. But now, I want to use on the component and I can't find working solution for sweetalert. I've tried several ways, but sweetalert still doesn't work.

I tried:

   const swal = inject($swal),

   Import VueSweetAlert2 from 'vue-sweetalert2';

   Import Swal from 'vue-sweetalert2';

   Import swal from 'vue-sweetalert2';

and some other ways.

How can I use SweetAlert in <script setup>???

Thanks. Pato



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source