the project created with vuecli changed the path of store. Npm run serve reported an error
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 //01
}
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 ("- sharpapp")