【发布时间】:2020-06-25 19:44:59
【问题描述】:
我正在尝试使用 vuex 将一些数据添加到一个安静的端点,并且 Chrome 不断抛出以下错误:vuex.esm.js?2f62:438 [vuex] unknown action type: POST_REGISTER - 你可以提供任何帮助/见解提供将非常有帮助。
这是我的设置。
在 vuex 模块中:
import actions from './actions.js'
export default {
actions: {}
}
在 actions.js 中:
import client from '@/services/authService.js'
export const POST_REGISTER = 'POST_REGISTER'
export default {
[POST_REGISTER]: (context, data) => client.post('auth/register', data)
}
在 authService.js 中
import axios from 'axios'
export default axios.create({
baseURL: '/api/v1/'
})
我来自 vue 组件的调用:
import {POST_REGISTER} from "@/store/auth/actions"
methods: {
createOrUpdate: function(login) {
this.login.username = login.username
this.login.password = login.password
this.$store.dispatch(POST_REGISTER, this.login)
}
}
}
【问题讨论】: