Vue का <component :is> आपको runtime पर निर्णय लिए गए कंपोनेंट को render करने देता है, और <KeepAlive> इन कंपोनेंट्स को कैश करता है ताकि वे स्विच करने के बाद और वापस लौटने पर अपनी state बनाए रखें।
<component :is> के साथ डायनामिक कंपोनेंट्स
<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); // which component to show
</script>
<template>
<button @click="current = tabs.home">Home</button>
<button @click="current = tabs.profile">Profile</button>
<component :is="current" /> <!-- renders whichever component `current` holds -->
</template>
