Vue-js <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>
