Steps to register global components:
Step 1: Create a new component as usual
What should be noted here is that this component needs to be given a signature. Before, it was just data and methods. Now it is named. In fact, it doesn't matter if you add this name before, but you only use this when registering global components.
<template>
<div>
<h3>现在我是一个全局性组件</h3>
</div>
</template>
<script>
export default {
name:"MyFirstComp"
}
</script>
<style>
</style>
Step 2: Register in main.js
//注册全局性组件
import GolbalComp from './components/GolbalComp.vue'
Vue.component("aNewName", GolbalComp)
Step 3: Use in App.vue
Different from other ordinary components, you can use it directly here. There is no need to introduce and register it. It has already been registered in main.js.