获取您的 Vue 服务器
App.vue
CompOne.vue
CompTwo.vue
main.js
 
<template>
  <div>
    <h3>Local Component</h3>
    <p>The CompOne.vue component is a local component and can only be used inside App.vue.</p>
    <comp-one /> <br>
    <comp-two />
  </div>
</template>

<script>
  import CompOne from './components/CompOne.vue';

  export default {
    components: {
      'comp-one': CompOne
    }
  }
</script>

<style>
  p {
    width: 200px;
  }
  #app div {
    border: dashed black 1px;
    margin: 10px;
    padding: 10px;
    display: inline-block;
  }
  .compOneDiv {
    background-color: lightgreen;
  }
  .compTwoDiv {
    background-color: lightcoral;
  }
</style>                  
<template>
    <div class="compOneDiv">
        <p>CompOne.vue (local)</p>
    </div>
</template>

<script></script>

<style></style>                  
<template>
    <div class="compTwoDiv">
        <p>CompTwo.vue (global)</p>
    </div>
</template>

<script></script>

<style></style>                  
import { createApp } from 'vue'

import App from './App.vue'
import CompTwo from './components/CompTwo.vue'

const app = createApp(App)
app.component('comp-two', CompTwo)
app.mount('#app')
                  
https://127.0.0.1:5173/