Laravel mix uses a webpack for building modules. I have two input files: header.js and main.js. They should (as planned) use the general state of the Vuex Store from the store.js file.

File store.js:

import Vue from 'vue'; import Vuex from 'vuex'; Vue.use(Vuex); export default new Vuex.Store({ state: { isVisible: true }, mutations: { show: state => state.isVisible = true, hide: state => state.isVisible = false } }) 

And in the main.js and header.js files I connect the import store from './store'; But they behave strangely, header.js is working properly, and main.js swears at Vuex: [vuex] already installed. Vue.use(Vuex) should be called only once. [vuex] already installed. Vue.use(Vuex) should be called only once. and further, respectively, no way to refer to $store .

By the way, the files on the page are connected in this order:

 <!--...--> <body> <script src="header.js"></script> <!--...--> <script src="main.js"></script> 

Correct me if I'm stupid, and please tell me how to do it right. Thank)

    1 answer 1

    You import the same thing two times, therefore you swear, import the dependency into bootstrap.js