组件注册
1.局部注册
2.全局注册
1.局部注册:,只能在当前注册的范围内使用
<template>
//展示组件
<Header />
<Main />
<Aside /> -->
<Parent/>
</template>
<script>
//引入组件
import Hander from "./pages/Hander.vue";
import Main from "./pages/Main.vue"
import Aside from "./pages/Aside.vue"
import Parent from "./components/Parent.vue";
export default {
//注入组件
components: {
//Hander,
Main,
Aside,
Parent
},
};
</script>
<style scoped></style>
局部注册:可以在全局任何一个组件内使用
import { createApp } from 'vue'
import App from './App.vue'
// 1. 导入需要被全局注册的组件
import Header from './pages/Hander.vue'
const app = createApp(App)
//在这个中间写组件的注册
app.component("Header",Header)
app.mount('#app')
<template>
<Header />
</template>
<script>
export default {
//注入组件
components: {
},
};
</script>
<style scoped></style>