Javascript 对象(…)不是Vuex存储的函数
我在VUE3中,我开始向Vue添加一个新的Vuex.Store,但我不断地遇到这个javascript错误。自从我使用Vue 3以来,我也在createStore上尝试了同样的方法,但仍然是一样的 我错过了什么Javascript 对象(…)不是Vuex存储的函数,javascript,vue.js,vuex,Javascript,Vue.js,Vuex,我在VUE3中,我开始向Vue添加一个新的Vuex.Store,但我不断地遇到这个javascript错误。自从我使用Vue 3以来,我也在createStore上尝试了同样的方法,但仍然是一样的 我错过了什么 const store = new Vuex.Store({ modules: { account: { namespaced: true, state: () => ({ }), getters: { isAdmin (
const store = new Vuex.Store({
modules: {
account: {
namespaced: true,
state: () => ({ }),
getters: {
isAdmin () { }
},
actions: {
login () { }
},
mutations: {
login () { }
}
}}
});
然后,我将以下内容添加到Vue存储:
new Vue({
router,
store,
render: h => h(App),
}).$mount('#app');
我错过了什么
const store = new Vuex.Store({
modules: {
account: {
namespaced: true,
state: () => ({ }),
getters: {
isAdmin () { }
},
actions: {
login () { }
},
mutations: {
login () { }
}
}}
});
完全错误
vuex.esm-browser.js?5502:644 Uncaught TypeError: Object(...) is not a function
at resetStoreState (vuex.esm-browser.js?5502:644)
at new Store (vuex.esm-browser.js?5502:387)
at createStore (vuex.esm-browser.js?5502:337)
at eval (main.js?56d7:37)
at Module../src/main.js (app.js:1105)
at __webpack_require__ (app.js:849)
at fn (app.js:151)
at Object.1 (app.js:1118)
at __webpack_require__ (app.js:849)
at checkDeferredModules (app.js:46)
如果您使用的是Vue 3,则需要使用Vuex 4
从“vuex”导入{createStore}
从“vue”导入{createApp}
const store=createStore({
国家(){
返回{
计数:1
}
}
})
const app=createApp({/*您的根组件*/})
应用程序使用(商店)
你能用堆栈跟踪发布完整的错误吗?我添加了完整的错误。好的,我安装了从stretch开始的所有东西,并按照你说的那样工作。但遗憾的是,我在VUE3的引导方面遇到了问题,所以我决定继续使用VUE2。