组件注册
<ul>
<li>局部注册</li>
</ul>
<pre><code class="language-javascript">&lt;template&gt;
&lt;HelloAndy&gt;&lt;/HelloAndy&gt;
&lt;/template&gt;
&lt;script setup&gt;
import HelloAndy from &quot;./components/HelloAndy.vue&quot;
&lt;/script&gt;</code></pre>
<hr />
<ul>
<li>全局注册</li>
</ul>
<pre><code class="language-javascript">// main.js
import { createApp } from 'vue'
import App from './App.vue'
import HelloAndy from &quot;./components/HelloAndy.vue&quot;
const app = createApp(App)
app.component(&quot;GlobalHelloAndy&quot;, HelloAndy)
app.mount('#app')</code></pre>
<pre><code class="language-javascript">&lt;template&gt;
&lt;GlobalHelloAndy&gt;&lt;/GlobalHelloAndy&gt;
&lt;/template&gt;
&lt;script setup&gt;
&lt;/script&gt;</code></pre>
<p>全局注册如果没有被引用,无法在项目打包时候 tree-shaking</p>