R
R
Ruslan Absalyamov2019-02-22 11:37:21
Vue.js
Ruslan Absalyamov, 2019-02-22 11:37:21

How can I make the connection of components in one file?

How can I not write global components in main. Drive them into one fight and through import drive everything into main.js
How main.js is implemented
now

import Vue from 'vue'
import router from './router'
import headImplant from './components/header/head.vue'
import footer from './components/footer/foot.vue'
import sidebar from './components/menu/sidebar.vue'
import store from './store'
import Modal from './components/modal/modal.vue';

window.eventBus = new Vue(); // события
window.Vue = Vue;
window.store = store;

Vue.component('modal',Modal);//Тут возможно будут еще компоненты

new Vue({
    el: '#app',
    router: router,
    store,
    components: {
        'head-app': headImplant,
        'footer-app': footer,
        'sidebar-app': sidebar
    }
});

and approximately I thought that to create a components.js file
import Vue from "vue/types/vue";
import Modal from './components/modal/modal.vue';

Vue.component('modal',Modal);

and connect in main.js
// import component from './components'
But it doesn't work like that, about how can it be implemented in js like this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Kovalchuk, 2019-02-22
@rusline18

components

import Modal from './modal';//Vue

export default {
        Modal,
}

main
import component from './components'
new Vue({
    el: '#app',
    router: router,
    store,
    components
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question