Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
94
rated 0 times [  99] [ 5]  / answers: 1 / hits: 11947  / 4 Years ago, tue, october 27, 2020, 12:00:00

I'm in Vue 3, I started with adding a new Vuex.Store to vue, but I continuously get this javascript error. I also tried the same thing with createStore since I use Vue 3, but it's still the same.


What am I missing?


const store = new Vuex.Store({
modules: {
account: {
namespaced: true,
state: () => ({ }),
getters: {
isAdmin () { }
},
actions: {
login () { }
},
mutations: {
login () { }
}
}}
});

Than I add to Vue as store:


new Vue({
router,
store,
render: h => h(App),
}).$mount('#app');

What am I missing?


Complete error


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)

More From » vue.js

 Answers
9

If you are using Vue 3 you need to use Vuex 4.


import { createStore } from 'vuex'
import { createApp } from 'vue'

const store = createStore({
state () {
return {
count: 1
}
}
})

const app = createApp({ /* your root component */ })
app.use(store)

https://vuex.vuejs.org/guide/#vuex-4-x-for-vue-3


[#2412] Thursday, October 22, 2020, 4 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
devinjadong

Total Points: 711
Total Questions: 117
Total Answers: 100

Location: Andorra
Member since Sat, May 27, 2023
1 Year ago
devinjadong questions
Thu, Feb 17, 22, 00:00, 2 Years ago
Wed, Dec 8, 21, 00:00, 2 Years ago
Fri, Oct 18, 19, 00:00, 5 Years ago
Fri, Sep 27, 19, 00:00, 5 Years ago
;