Nested router-views: don't invoke lifecycle, when child route changes #14035
Replies: 2 comments 3 replies
-
(Your old discussion thread: #13243) In your <router-view v-slot="{ Component, route }" v-else>
<Transition appear mode="out-in" :css="false" :key="route">
<component :is="Component" />
</Transition>
</router-view>
See this one which doesn't makes everything re-render on each route change. It uses the most basic We can't precisely know what's going on with the loading, transition, etc. stuff. So, can't say much about the rest. |
Beta Was this translation helpful? Give feedback.
-
@yusufkandemir I dare to address you again with this topic, hoping you find a moment to take a glimpse I posted here: The key problem is that I check However, changes between BTW: An important input came from Danny's Quasar-iOS Youtube tutorials: Thank you! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In my little app I want to use at least 2 layouts, important part being that there shall be animations once a route is entered / left. In the "MainLayout" (
https://[domain]/catalog-of-works
) the menu is constructed: whenever a link is clicked there, a child template is supposed to be loaded("(https://[domain]/catalog-of-works/:category
).The problem is that whenever a child element (the "nested route") is loaded, a "complete route change" is detected and invokes "onMounted" of "MainLayout", too.
This is not what I want to achieve. Instead, the
onMounted
andonLeave
lifecycle hooks of "MainLayout" should only be invoked, when the main domain "https://[domain]/catalog" is left and changes to another domain (e.g. "https://[domain]/" or "https://[domain]/books").I put together a really ugly template here on stackblitz:
https://stackblitz.com/edit/quasarframework-enyltx?file=src%2Flayouts%2FMainLayout.vue
A little red square fading in at the top left indicates that the "onMounted" method is called, whenever another catalog category is invoked. (Also, see console, where "onBeforeAppear", "onAppear" and "onMounted" are logged).
But, as mentioned: this is not what I want. The square (and therefore the menu) shall only "react" on first load and on leave.
Any idea what I have to do to fix this?
For conveniance, here is the content of
routes.js
:Beta Was this translation helpful? Give feedback.
All reactions