component :is — dynamic component rendering.
Basic:
1<script setup>2import TabA from "./TabA.vue"3import TabB from "./TabB.vue"4import { ref } from "vue"56const currentTab = ref(TabA)7</script>89<template>10 <button @click="currentTab = TabA">Tab A</button>11 <button @click="currentTab = TabB">Tab B</button>12 <component :is="currentTab" />13</template>
With keep-alive:
1<KeepAlive>2 <component :is="currentTab" />3</KeepAlive>
Key: :is for dynamic components.