N
Nuxt8mo ago
reinacchi

nuxt loading

i don't know how you call this, but is there way to do that?
30 Replies
pyplacca
pyplacca8mo ago
Nuxt
· Nuxt Components
Display a progress bar between page navigations.
reinacchi
reinacchiOP8mo ago
do ionly need to add that one code inside my app.vue? because it doesn't show up at all
pyplacca
pyplacca8mo ago
Yeah, just that. It shows when navigating from one page to another or when fetching data
reinacchi
reinacchiOP8mo ago
how would i do it for page rendering? i have images load upon redirecting to a page but it renders so slow
pyplacca
pyplacca8mo ago
Nuxt
useLoadingIndicator · Nuxt Composables
This composable gives you access to the loading state of the app page.
pyplacca
pyplacca8mo ago
Or are you asking about showing loading skeletons for images when loading?
reinacchi
reinacchiOP8mo ago
i tried using this but it keeps getting stuck in loading state. am i missing something?
pyplacca
pyplacca8mo ago
Do you call the stop method? …after the images have loaded?
reinacchi
reinacchiOP8mo ago
how would i determine whether it's loaded?
pyplacca
pyplacca8mo ago
You can listen to the load event if you’re using an img element
reinacchi
reinacchiOP8mo ago
how'd you do that?
pyplacca
pyplacca8mo ago
MDN Web Docs
HTMLElement: load event - Web APIs | MDN
The load event fires for elements containing a resource when the resource has successfully loaded. Currently, the list of supported HTML elements are: , , , <img>, <link>, <object>, <script>, <style>, and <track>.
reinacchi
reinacchiOP8mo ago
alright, i'll try
pyplacca
pyplacca8mo ago
I’ll try and get you a sample code when I get home. Provided you haven’t resolved it by then
reinacchi
reinacchiOP8mo ago
alright, thank you so much :D
reinacchi
reinacchiOP8mo ago
in case you might misunderstand what i'm trying to imply, here's the showcase. so apparently there should be collection of images inside the /uploads page, but they're not fully rendered yet. i wanted to create a loading before being redirected to upload page until the images are loaded
reinacchi
reinacchiOP8mo ago
also you can see here the images' border. the images themselves haven't showed up
No description
pyplacca
pyplacca8mo ago
So you want to block the navigation until the images have been loaded?
reinacchi
reinacchiOP8mo ago
yes
pyplacca
pyplacca8mo ago
Hmm. I’m not sure how that’s going work if the elements don’t exist in the DOM Unless you’re trying to fetch a list of posts from a server before navigating. If so you can use useAsyncData in the page the displays the list of posts
reinacchi
reinacchiOP8mo ago
do you have a sample code for that?
pyplacca
pyplacca8mo ago
Nuxt
useAsyncData · Nuxt Composables
useAsyncData provides access to data that resolves asynchronously in an SSR-friendly composable.
pyplacca
pyplacca8mo ago
I’ll get you samples for both suggestions once I get home
reinacchi
reinacchiOP8mo ago
alright, thanks
pyplacca
pyplacca8mo ago
This is technically possible but I don’t think it’s worth the effort. It would even be really bad for user experience @furokuri https://stackblitz.com/edit/github-ctwyq4?file=app.vue,components%2FImage.vue,pages%2Findex.vue,pages%2Fposts.vue
reinacchi
reinacchiOP8mo ago
thank you, i'll try now it works! thank you so much :D small question, how would i apply the loading to all pages?
pyplacca
pyplacca8mo ago
Which loading?
reinacchi
reinacchiOP8mo ago
the loading indicator i want it to show to basically all pages i navigate through
pyplacca
pyplacca8mo ago
Insert it in the app.vue You can check the app.vue file in the demo
reinacchi
reinacchiOP8mo ago
alright
Want results from more Discord servers?
Add your server