Subscribe on changes!

In the keepAlive state, v-if switches subcomponents and does not re-execute the onActivated life cycle

avatar
Aug 10th 2023
<template>
  <button @click="setCom(Com2)">com2</button>
  <button @click="setCom(Com3)">com3</button>
  <KeepAlive>
    <component :is="com" />
  </KeepAlive>
</template>
avatar
Aug 10th 2023

KeepAlive does not work on nested children. it only keeps a component tree alive if the immediate children in its slot are unmounted.