N
Nuxt2y ago
Eric

Data no loading when refreshing the page

Hello! I have a small problem that is really bugging me. I use pinia to store all the data imported from DIrectus. In my components I simply have this: import { useItemStore } from '@/stores/items'; const itemStore = useItemStore() const items = ref(itemStore.getItems) then, I iterate through the items with a v-for to render all my items. Straight forward and classic I think. It works fine but if I refresh the page, then it doesn't render and nothing appears on the page. Then if I navigate to another page and I come back, it works just fine and all items are shown. I thaught that because refs are reactive, the DOM is supposed to update whenever the ref is updated. Am I wrong? And I'm not quite sure if I need to use refs or not... I probably miss a small detail, but I can't figure it out. Anyone knows the solution to this problem?
13 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Eric
EricOP2y ago
well. At first, I realised I could just use {{ itemStore.getItems }} in the html. But I just wanted to store it in variable with a simple name so it's more readable. But maybe it's just a bad idea
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Eric
EricOP2y ago
I tried as well. but it produces the same problem. but I'll try again. Maybe I had multiple bugs..
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Eric
EricOP2y ago
oohh yeah.. the second one is nice. I didn(t think of renaming it like that. sold! Thak you so much for that!! 🙂
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Eric
EricOP2y ago
also. I seem to have a similar problem with some css. I have a page that works just fine, until I reload it. IS it ok to put my css files in the assets folder?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Eric
EricOP2y ago
I use css files for some classes that are shared throughout multiple components yeah. ok. I just get this weird bug when I refresh the page. The css rules aren't applied. If I navigate to another page and come back, then it works again
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Eric
EricOP2y ago
ok thanks! I'll checkout your project too!
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server