In my SPA app, I have an <app-view>
wrapper which handles base app code (load user data, render navbar and footer, etc) and has a slot
for rendering the actual page. This slot is rendered only if the user data is available.
This wrapper was created because some pages needed a different base code, therefore I couldn't keep this base code in the main app containing <router-view>
anymore.
I tried looking if vue-router provides advanced options or suggests a design pattern for switching base code, didn't find anything.
The problem is that the child component will be rendered before the parent component is mounted, i.e. before the parent decides not to render the child component (because it's loading user data). This causes errors like undefined as no attribute foo
.
Because of that, I'm looking for a way to defer child rendering until its parent is mounted.
v-cloak
? – birdspiderv-if
in a<slot>
tag. I wonder...? – Roy J