Built-in special elements
A “meta component” for rendering dynamic
components or elements.
The actual component to render is determined by
the is prop.
- When is is a string, it could be either an
HTML tag name or a component’s registered
name. - Alternatively, is can also be directly bound to
the definition of a component.
<script setup>
import Foo from './Foo.vue'
import Bar from './Bar.vue'
</script>
<template>
<component :is="Math.random() > 0.5 ? Foo : Bar" />
</template>
<component :is="href ? 'a' : 'span'"></component>