vue引入store报错 请问是怎么回事

新手上路,请多包涵

使用vuecli创建的项目 改动了store的路径 npm run serve报错

clipboard.png

clipboard.png

index.js
import Vue from 'vue';
import Vuex from 'vuex';
import login from "./login";

Vue.use(Vuex)
const state = {};
const getters = {};
const mutations = {};
const actions = {};
const modules = {
    login: login
}
export default new Vuex.Store({
    //全部组件化
    state,
    getters,
    mutations,
    actions,
    modules
})
const state = {
    username: '',
    user_state: 0 //0登陆,1已登陆
}
const mutation = {
    chang_username(state, name) {
        state.username = name;
    },
    chang_userstate(state, userstate) {
        state.user_state = userstate;
    }
}
const action = {
    //模拟出发登陆  3s后成功  
    async triggerLogin(ctx) {
        await setTimeout(() => {
            ctx.commit('chang_username', name)
            ctx.commit('chang_userstate', 1)
        }, 3000)
    }
}
export default {
    namespaced: true,
    state,
    mutation,
    action
}

main.js
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css';
import '@/assets/reset.css'

Vue.config.productionTip = false

Vue.use(ElementUI);

new Vue({

router,
store,
render: h => h(App)

}).$mount('#app')

阅读 2.8k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题