Vue


组件注册

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

页面列表

ITEM_HTML