Vue registers components with one click

  1. Components/index.js

import Vue from 'vue';

import Button from "./Button" // Components/Button/index.vue
import Input from "./Input" // Components/Input/index.vue

const OWNER_UI = {
    Button,
    Input
}

Object.keys(OWNER_UI).forEach(uiName= > {
    Vue.component(uiName, OWNER_UI[uiName])
})

export default OWNER_UI;
Copy the code
  1. main.js
import Vue from 'vue'
import App from './App.vue'

import OWNER_UI from "./Components"
Vue.extend(OWNER_UI)

new Vue({
  render: h= > h(App),
}).$mount('#app')

Copy the code