add dynamic global component registration

This commit is contained in:
Axolotle 2020-10-23 17:18:34 +02:00
parent 19ae0ccada
commit 19d3e58d3f
3 changed files with 7 additions and 12 deletions

View file

@ -1,5 +0,0 @@
export { default as FormItemHelper } from './FormItemHelper'
export { default as InputItem } from './InputItem'
export { default as SelectItem } from './SelectItem'
export { default as CheckboxItem } from './CheckboxItem'

View file

@ -1,3 +0,0 @@
export { default as Icon } from './Icon'
export { default as Breadcrumb } from './Breadcrumb'
export { FormItemHelper, InputItem, SelectItem, CheckboxItem } from './formItems'

View file

@ -6,17 +6,20 @@ import i18n from './i18n'
import router from './router'
import store from './store'
import * as globalsComponents from './components/globals'
Vue.config.productionTip = false
// Styles are imported in `src/App.vue` <style>
Vue.use(BootstrapVue)
// Register global components
for (const component of Object.values(globalsComponents)) {
const requireComponent = require.context('@/components/globals', true, /\.(js|vue)$/i)
// For each matching file name...
requireComponent.keys().forEach((fileName) => {
// Get the component
const component = requireComponent(fileName).default
// Globally register the component
Vue.component(component.name, component)
}
})
new Vue({
i18n,