fumeapp / tailvue

Vue components built for Nuxt3|Vue3 powered by Windi CSS|tailwindcss
157 stars 14 forks source link

Nuxt 3 document is not defined when refresh #13

Closed ldiellyoungl closed 1 year ago

ldiellyoungl commented 1 year ago

i use const $toast = useToast() in section if i refresh page then document is not defined. but if i use $toast = useToast() in function and execute it toast and modals work is fine. what is my problem? sorry for bad english

tcampbPPU commented 1 year ago

Just so I understand correctly just declaring the composable like:

<script lang="ts" setup>
const $toast = useToast()
</script>

With Nuxt 3 you should do like this instead and be importing from useNuxtApp

<script lang="ts" setup>
import { useNuxtApp } from '#app'
const { $toast } = useNuxtApp()
</script>
tcampbPPU commented 1 year ago

You can see an example of this in our Nuxt 3 Template hopefully that helps out