【发布时间】:2021-10-28 13:21:45
【问题描述】:
当我尝试调用模块时,我收到错误 [vuex] unknown action type: signUp 这也不起作用,有什么问题? this.$store.dispatch('auth/signUp', this.form)
方法
methods:{
signUp() {
this.$store.dispatch('signUp', this.form)
}
}
商店
import Vue from 'vue'
import Vuex from 'vuex'
import auth from './modules/auth'
Vue.use(Vuex)
export default function createStore() {
return new Vuex.Store({
state() {
return {}
},
mutations: {},
actions: {},
modules:{
auth,
}
})
}
模块(在 src/store/modules/auth.js 中)
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
export default function createStore() {
return new Vuex.Store({
state() {
return {}
},
mutations: {},
actions: {
signUp({commit, getters}, data) {
debugger
},
},
})
}
【问题讨论】:
-
一个模块根本不应该包含
Vuex.Store和Vue.use(Vuex)
标签: javascript vue.js vuex vuex-modules