/*全局组件, 多个界面使用*/
globalComponent.vue
<template>
<div>GlobalComponent</div>
</template>
<script>
export default {
name: 'GlobalComponent'
</script>
<style scoped></style>
/*main.js*/
import GlobalComponent from './components/GlobalComponent'
Vue.component(GlobalComponent.name, GlobalComponent)
效果图:
/*单个组件 单个页面使用*/
/*child2.vue 子组件*/
<template>
<div>child2</div>
</template>
<script>
export default {
name: 'Child2',
</script>
<style scoped></style>
/*父组件*/
<template>
<div>
<Child2 />
</template>
<script>
import Child2 from './Home/Child2.vue'
export default {
name: 'Home',
components: { Child2 },
</script>
<style scoped></style>
效果图: