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>
