So now, I'm utilizing it to flash messages from every response to my request on myAuthenticated.vue
<script setup>
import Navbar from '@/Components/Navbar.vue'
import Sidebar from '@/Components/Sidebar.vue'
import { getCurrentInstance, computed, watch } from 'vue'
import { getAuthenticatedUser } from '@/helper.js'
import { usePage } from '@inertiajs/vue3'
import { debounce } from 'lodash'
const { $swal } = getCurrentInstance().appContext.config.globalProperties
const user = getAuthenticatedUser()
const flashMessage = computed(() => {
const flash = usePage().props.flash
return flash
})
watch(flashMessage, debounce((newVal) => {
if (newVal) {
$swal(newVal.title || 'Alert', newVal.message, newVal.variant)
}
}, 300), { // Debounce after 1 second
immediate: true, // Show initial flash message
})
</script>
However upon refreshing/entering the page. I'm getting this error, I tried onMounted and onUpdated before. I tried now the combination of computed and watch. It seems the case is still the same.
vue-sweetalert.mjs:1056 Uncaught TypeError: Cannot read properties of null (reading 'jquery')
I use this Vue Sweetalert 2 in my
Laravel 11
,Inertia JS
, andVue 3
.In my
app.js
I properly registered the sweetalert.So now, I'm utilizing it to flash messages from every response to my request on my
Authenticated.vue
However upon refreshing/entering the page. I'm getting this error, I tried
onMounted
andonUpdated
before. I tried now the combination ofcomputed
andwatch
. It seems the case is still the same.vue-sweetalert.mjs:1056 Uncaught TypeError: Cannot read properties of null (reading 'jquery')