I'm using laravel together with VueJS and I never entirely understood the logic behind the 'import', 'use' and 'component' used in app.js. Maybe someone could give me a hint/link on how to use them correctly.
To use custom vue components (separate files) in a blade I need to define them in the root 'app.js' file.
Now here I'm kind of lost. Inside the app.js file there are:
window.Vue = require('vue');
[..]
Vue.component('my-vue-component', require('./components/my-vue-component.vue').default);
[..]
import Vue from 'vue';
import VueDraggableResizable from 'vue-draggable-resizable';
[..]
Vue.use(VueClipboard);
as well as:
const app = new Vue({
el: '#app',
components: {
dropZone: vue2Dropzone,
draggable, Hooper, Slide, HooperPagination,
'my-vue-component': MyVueComponent,
[..]
},
What are 'component', 'import', 'use' and 'components:{' doing exactly?
- 'component' probably defines the component file with the template.
- 'import' -> I dont' know what that does.
- 'use' -> also no idea.
- 'components: {' -> probably makes the link back to the template file by passing the name of the component.