Vue کا <component :is> آپ کو runtime پر فیصلہ شدہ component کو render کرنے دیتا ہے، اور <KeepAlive> ان components کو cache کرتا ہے تاکہ وہ اپنی state کو محفوظ رکھیں جب switch ہو کر واپس آیں۔
<component :is> کے ساتھ Dynamic components
<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>
