After defining the main page of my vue app this way:
<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... */
}
I have a Dashboard UI with various routes and sub-route paths to display different pages. However, I want the app-header to remain at the top of all pages (components).
The issue arises when I click on any button that changes vue-router's route to another page, causing the app-header to be recreated (the created() lifecycle hook function is called).
I am puzzled by this behavior because I added keep-alive, expecting it to render only once. Any insights into why this is happening would be greatly appreciated.
I've searched extensively online for a solution but haven't been able to find one yet.
Thank you in advance for your assistance.