Vues <component :is> låter dig rendera en komponent som bestäms vid körning, och <KeepAlive> cachelagrar dessa komponenter så att de bevarar sitt tillstånd när de växlas bort och tillbaka.
Dynamiska komponenter med <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>
