App.vue
ChildComp.vue
main.js
<template>
<h2>Example Built-in 'is' Attribute</h2>
<p>The component element below is set to be a component by the use of 'is="child-comp"'.</p>
<component is="child-comp"></component>
</template>
<template>
<div>
<h3>ChildComp.vue</h3>
<p>This is the child component</p>
</div>
</template>
<style scoped>
div {
border: solid black 1px;
background-color: lightgreen;
padding: 10px;
max-width: 250px;
margin-top: 20px;
}
</style>
import { createApp } from 'vue'
import App from './App.vue'
import ChildComp from './components/ChildComp.vue'
const app = createApp(App)
app.component('child-comp', ChildComp)
app.mount('#app')