componentタグでコンポーネントを動的に切り替える

// :isに渡した文字列のコンポーネントに変わる
<component :is="currentComponent"></component>
 
<button @click="currentComponent = 'Home'"></button>
<button @click="currentComponent = 'About'"></button>
// ボタンで切り替え

このままでは切り替えるたびにコンポーネントがcreated/destroyedされるが、keep-aliveタグによってそれを防げる(activated/deactivatedになる)

<keep-alive>
    <component :is="currentComponent"></component>
</keep-alive>