目錄結(jié)構(gòu)如下 我在axios.js中想使用vuex的state里面的數(shù)據(jù)我打印console.log(store)報(bào)錯(cuò)undefined 如果直接引入import state from '../store/state'就可以獲取到state里面的數(shù)據(jù) 但是下面這樣寫就不行 這是為什么?|--src
|--api
|--axios.js
|--store
|--index.js
|--state.js
|--mutations.js
|--actions.js
|--components...src/api/axios.jsimport Vuex from 'vuex'import store from '../store/index.js'console.log(store)src/store/index.jsimport 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,
})
添加回答
舉報(bào)
0/150
提交
取消