I. Introduction
1. <component/>
Is a "meta component" used to render dynamic components or elements.
Second, <component/>
use
1. <component/>
The function is similar to tab
components, which can be used to switch components
2. is
The attribute determines component
the currently rendered component . is
The attribute can be a component or a string. When it is a string, it represents the registered name or tag name of the component.
interface DynamicComponentProps {
is: string | Component
}
<script setup>
import Foo from './Foo.vue'
import Bar from './Bar.vue'
</script>
<template>
<component :is="Math.random() > 0.5 ? Foo : Bar" />
</template>
3. component
Arbitrary parameters and events can be passed on the dynamic component, and will be is
received by all current components on the component
4. In short, component
it is like a container that is
decides what components to render based on attributes