N
Nuxt9mo ago
reinacchi

nuxt loading

i don't know how you call this, but is there way to do that?
30 Replies
pyplacca
pyplacca9mo ago
Nuxt
· Nuxt Components
Display a progress bar between page navigations.
reinacchi
reinacchiOP9mo ago
do ionly need to add that one code inside my app.vue? because it doesn't show up at all
pyplacca
pyplacca9mo ago
Yeah, just that. It shows when navigating from one page to another or when fetching data
reinacchi
reinacchiOP9mo ago
how would i do it for page rendering? i have images load upon redirecting to a page but it renders so slow
pyplacca
pyplacca9mo ago
Nuxt
useLoadingIndicator · Nuxt Composables
This composable gives you access to the loading state of the app page.
pyplacca
pyplacca9mo ago
Or are you asking about showing loading skeletons for images when loading?
reinacchi
reinacchiOP9mo ago
i tried using this but it keeps getting stuck in loading state. am i missing something?
pyplacca
pyplacca9mo ago
Do you call the stop method? …after the images have loaded?
reinacchi
reinacchiOP9mo ago
how would i determine whether it's loaded?
pyplacca
pyplacca9mo ago
You can listen to the load event if you’re using an img element
reinacchi
reinacchiOP9mo ago
how'd you do that?
pyplacca
pyplacca9mo 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
reinacchiOP9mo ago
alright, i'll try
pyplacca
pyplacca9mo ago
I’ll try and get you a sample code when I get home. Provided you haven’t resolved it by then
reinacchi
reinacchiOP9mo ago
alright, thank you so much :D
reinacchi
reinacchiOP9mo 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
reinacchiOP9mo ago
also you can see here the images' border. the images themselves haven't showed up
No description
pyplacca
pyplacca9mo ago
So you want to block the navigation until the images have been loaded?
reinacchi
reinacchiOP9mo ago
yes
pyplacca
pyplacca9mo 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
reinacchiOP9mo ago
do you have a sample code for that?
pyplacca
pyplacca9mo ago
Nuxt
useAsyncData · Nuxt Composables
useAsyncData provides access to data that resolves asynchronously in an SSR-friendly composable.
pyplacca
pyplacca9mo ago
I’ll get you samples for both suggestions once I get home
reinacchi
reinacchiOP9mo ago
alright, thanks
pyplacca
pyplacca9mo 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
reinacchiOP9mo 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
pyplacca9mo ago
Which loading?
reinacchi
reinacchiOP9mo ago
the loading indicator i want it to show to basically all pages i navigate through
pyplacca
pyplacca9mo ago
Insert it in the app.vue You can check the app.vue file in the demo
reinacchi
reinacchiOP9mo ago
alright
Want results from more Discord servers?
Add your server