I defined the main page of my vue app to look like this:
<div class="wrapper">
<keep-alive>
<app-header></app-header>
</keep-alive>
<router-view></router-view>
</div>
<script>
import appHeader from '../components/Header';
export default {
components: {
appHeader
}
/* etc... */
}
My app UI is basically this Dashboard, with many different routes and sub-routes paths to show many pages, but in all pages (components) I want to show the app-header at the top of the page.
The problem is that I noticed recently, with every button clicked (that changes vue-router's route to another page), the app-header gets recreated (the created() lifecycle hook function is called)
I really don't understand why, since I added keep-alive, shouldn't it be rendered once?
Please help me figure this out, I am stuck, I literally researched the entire internet about it.
Thanks in advance