directory structure is as follows: I want to use the data in vuex"s state in axios.js
I print console.log (store)
error undefined
if you directly introduce import state from". / store/state"
, you can get the data in state, but you can"t write it this way. why?
|--src
|--api
|--axios.js
|--store
|--index.js
|--state.js
|--mutations.js
|--actions.js
|--components
...
src/api/axios.js
import Vuex from "vuex"
import store from "../store/index.js"
console.log(store)
src/store/index.js
import Vue from "vue"
import Vuex from "vuex"
import state from "./state"
import mutations from "./mutations"
import actions from "./actions"
Vue.use(Vuex)
export default new Vuex.Store({
state,
mutations,
actions,
})