Built-in components: component

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 tabcomponents, which can be used to switch components

2. isThe attribute determines componentthe currently rendered component . isThe 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. componentArbitrary parameters and events can be passed on the dynamic component, and will be isreceived by all current components on the component

4. In short, componentit is like a container that isdecides what components to render based on attributes

Guess you like

Origin blog.csdn.net/qq_40340943/article/details/129144761
Recommended