vuex报错:vuex.esm-bundler.js:1036 [vuex] unknown action type: user/getLoginUser
初次使用vuex仓库,在定义了 store后,使用store.dispatch
一直报错找不到actions
方法
文件目录如下,user.ts
被添加进index.ts
里:
index.ts:
调用actions的代码:
user里面确实有这个方法,但是一直报错vuex.esm-bundler.js:1036 [vuex] unknown action type: user/getLoginUser
,store.dispatch找不到actions方法。
解决方法
把路径改一下就好了,去掉user/,改为: