Registering Components
You have written BookCard.vue. Now BookList.vue wants to show several of them. Writing <BookCard /> in its template does nothing yet: Vue has to be told what the tag BookCard means. That is what registration does.
The rule
Import it to use it here;
app.componentto use it everywhere.
Local registration is the everyday way. In <script setup>, importing a component is all it takes:
<!-- BookList.vue -->
<script setup>
import BookCard from './BookCard.vue'
</script>
<template>
<section>
<BookCard />
<BookCard />
</section>
</template>The import registers BookCard for this one file. Other components cannot use it unless they import it too.
Global registration makes a component available in every template of the app. You do it once on the app instance, before mounting:
// main.js
import { createApp } from 'vue'
import App from './App.vue'
import BaseButton from './components/BaseButton.vue'
createApp(App)
.component('BaseButton', BaseButton)
.mount('#app')Global looks convenient, but it has costs. A global component is included in the final bundle even if no page uses it, because the build tool cannot tell. And a reader of BookList.vue cannot see where BaseButton comes from. That is why local registration is the default choice.
Names: use PascalCase for component names, like BookCard. In a .vue template you may write <BookCard /> or <book-card />; both work. If you ever write templates directly inside an HTML page (an "in-DOM" template), the browser lower-cases tag names, so there you must use <book-card></book-card> with a closing tag.