tol*_*lga 4 javascript vue.js vuex
我在 Vue 3 中,我开始向 vue 添加一个新的 Vuex.Store,但我不断收到此 javascript 错误。自从我使用 Vue 3 以来,我也用createStore尝试了同样的事情,但它仍然是一样的。
我错过了什么?
const store = new Vuex.Store({
modules: {
account: {
namespaced: true,
state: () => ({ }),
getters: {
isAdmin () { }
},
actions: {
login () { }
},
mutations: {
login () { }
}
}}
});
Run Code Online (Sandbox Code Playgroud)
比我添加到 Vue 作为商店:
new Vue({
router,
store,
render: h => h(App),
}).$mount('#app');
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
完全错误
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)
Run Code Online (Sandbox Code Playgroud)
如果您使用的是 Vue 3,则需要使用 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)
Run Code Online (Sandbox Code Playgroud)
https://vuex.vuejs.org/guide/#vuex-4-x-for-vue-3
| 归档时间: |
|
| 查看次数: |
4327 次 |
| 最近记录: |