I've created a small app that consists of two main components and I am using vue router to route between components.
First component is called MoviesList and the second one is called Movie. I've registered them in routes js file.
const routes = [
{
path: '/',
name: 'Home',
component: MoviesList
},
{
path: '/:movieId',
name: 'Movie',
component: Movie
}
]
And my App.vue template looks like this
<template>
<router-view></router-view>
</template>
How can I make MovieList component cached or so to say like it is wrapped with <keep-alive>
tags?
Desired outcome would be to make MovieList component cached and Movie component not.
I want to do that because MovieList component has a method that runs on mounted() hook and whenever I switch routes and come back that method runs again because component is re-rendered.