是在main.js中,通过import和Vue.conponent进行组件注册的。
import Vue from 'vue'
import App from './App.vue'
import Header from './components/Header.vue'
import Content from './components/Content.vue'
import Button from './components/Buttom.vue'
Vue.component('myHeader',Header)
Vue.component('myContent',Content)
Vue.component('myButton',Button)
new Vue({
el: '#app',
render: h => h(App)
})
实在App,vue里的 script 标签内定义
<template>
<div id="app">
<myHeader></myHeader>
<myContent></myContent>
<myButton></myButton>
</div>
</template>
<script>
import Header from './components/Header.vue'
import Content from './components/Content.vue'
import Button from './components/Buttom.vue'
export default {
name: 'app',
components: {
'myHeader': Header,
'myContent': Content,
'myButton': Button
},
}
</script>