Vue యొక్క <component :is> మీకు రన్టైమ్లో నిర్ణయించిన కాంపోనెంట్ను రెండర్ చేయటానికి అనుమతిస్తుంది, మరియు <KeepAlive> ఈ కాంపోనెంట్లను కాష్ చేయడం ద్వారా అవి దూరంగా మరియు తిరిగి స్విచ్ చేయబడినప్పుడు వాటి స్థితిని సంరక్షించాయి.
<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>
