Vue의 <component :is>는 런타임에 결정된 컴포넌트를 렌더링하게 해주고, <KeepAlive>는 그러한 컴포넌트를 캐싱하여 전환되어 떠났다가 돌아올 때 상태를 보존합니다.
<component :is>로 동적 컴포넌트
vue
<script setup>
import { ref, shallowRef } from "vue";
import TabHome from "./TabHome.vue";
import TabProfile from "./TabProfile.vue";
const tabs = { home: TabHome, profile: TabProfile };
const current = shallowRef(TabHome); // 어떤 컴포넌트를 표시할지
</script>
<template>
<button @click="current = tabs.home">Home</button>
<button @click="current = tabs.profile">Profile</button>
<component :is="current" /> <!-- `current`가 담고 있는 컴포넌트를 렌더링 -->
</template>
