目录结构如下 我在axios.js中想使用vuex的state里面的数据
我打印console.log(store)报错undefined 如果直接引入import state from '../store/state'就可以获取到state里面的数据 但是下面这样写就不行 这是为什么?
|--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,
})
鸿蒙传说
烙印99
达令说
随时随地看视频慕课网APP
相关分类