报错:[vuex] unknown action type: user/login
问题:
vue 项目,vuex中使用 this.$store.dispatch('user/login', this.loginForm) 无法获取actions。
并报错:[vuex] unknown action type: user/login
原因:
在store里面的文件,命名空间属性(namespaced: true)写错导致的。
解决方法:
1. export default {
2. // namespace: true, 错误写法
3.
4. namespaced: true, // 正确写法
5. state,
6. mutations,
7. actions
8. }
0 评论