Keep-alive
Basic implementation
<KeepAlive>
<component :is="activeComponent" />
</KeepAlive>Include and exclude\
<KeepAlive include="a,b">
<component :is="view" />
</KeepAlive>Hooks
<script setup>
import { onActivated, onDeactivated } from 'vue'
onActivated(() => {
// called on initial mount
// and every time it is re-inserted from the cache
})
onDeactivated(() => {
// called when removed from the DOM into the cache
// and also when unmounted
})
</script>Max usage
Last updated