What do you mean with main.js? It doesn't matter what filename you use. You need to make sure the file name you give it is used in the webpack (Laravel mix) configuration and is included on the page. That's it ;)
Jun 6, 2020
3
Level 27
Component Registration
I found this file on an ecommerce for component registration. I wonder if there is any reference to create this whole scripts? I don't know what are all the neccessary scripts for component registration?
This is the only reference I found: ref: https://vuejs.org/v2/guide/components-registration.html
app.js
import Vue from 'vue'
import SuiVue from 'semantic-ui-vue'
import axios from 'axios'
import numeral from 'numeral-es6'
import Autocomplete from 'vuejs-auto-complete'
import VueContentPlaceholders from 'vue-content-placeholders'
Vue.use(SuiVue)
Vue.use(VueContentPlaceholders)
// Carts
Vue.component('cart-total-price', require('./components/carts/TotalPrice').default);
Vue.component('cart-button-global', require('./components/carts/buttons/Global').default);
Vue.component('cart-button-wishlist', require('./components/carts/buttons/Wishlist').default);
Vue.component('cart-select-maturities', require('./components/carts/SelectMaturities').default);
Vue.component('cart-select-variants', require('./components/carts/SelectVariants').default);
Vue.component('cart-detail-action-button-wrapper', require('./components/carts/DetailActionButtonWrapper').default);
// MasterData
Vue.component('master-nutrition', require('./components/master/MasterNutrition').default);
Vue.component('master-benefit', require('./components/master/MasterBenefit').default);
Vue.component('master-format', require('./components/master/MasterFormat').default);
Object.defineProperty(Vue.prototype, '$bus', {
get() {
return this.$root.bus;
}
});
window.bus = new Vue();
window.axios = axios;
window.numeral = numeral;
Vue.prototype.$axios = window.axios;
Vue.prototype.$numeral = window.numeral;
window.Vue = Vue
window.app = new Vue({
el: '#app',
data: {
bus: bus // Here we bind our event bus to our $root Vue model.
}
});
I also wonder where is the main.js that I normally created when building vue files?
Please or to participate in this conversation.