I have a page structure of:
pages/
users/
_userid.vue
users.vue
with <nuxt-child/> meta-component inside users.vue
. So basically I have a list of items, which is always shown when navigated at /users/*
, and a pane for item details, which is shown when navigated at /users/1
etc. In the list page I use fetch
method to fetch the user_list
from my API. Then I render items as a list of <nuxt-link :to="'/users/' + user.id" v-for="user in user_list">
. So far it works okay. I just need to mention that the list has some own state, like filtering.
Then, when I want to get back from the particular item details to the list, thus from /users/1
to /users
I don't want to lose the state of my list. Which, unfortunately, happens, as the fetch method of users.vue
is being called again.
So I thought: maybe there should be a way to figure out from which route do we navigate from, so I can disable fetching when returning from details view to the list-only view?
Is there a way for nuxt to play nicely with https://router.vuejs.org/en/advanced/navigation-guards.html?
<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This feature request is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c972">#c972</a>)</em></sub></div>