javascript - VueJS: Cannot read property 'dispatch' of undefined - Stack Overflow

I start my simple project with VueJS and Vuex. And I have a problem witch calling method from store.Wh

I start my simple project with VueJS and Vuex. And I have a problem witch calling method from store. When I click my button in console I see this error

Uncaught TypeError: Cannot read property 'dispatch' of undefined at VueComponent.onSignin

Here is my ponent with button which should call dispatch
Login ponent.

And here is my store index.js Vuex.Store

And here you can find full repo

I read many topics on another forum but I stil don't know why it is not work, because I do similar project few months ago and it works correctly.

I start my simple project with VueJS and Vuex. And I have a problem witch calling method from store. When I click my button in console I see this error

Uncaught TypeError: Cannot read property 'dispatch' of undefined at VueComponent.onSignin

Here is my ponent with button which should call dispatch
Login ponent.

And here is my store index.js Vuex.Store

And here you can find full repo

I read many topics on another forum but I stil don't know why it is not work, because I do similar project few months ago and it works correctly.

Share edited Sep 12, 2018 at 19:04 Bartlomiej Mroczek asked Sep 12, 2018 at 18:59 Bartlomiej MroczekBartlomiej Mroczek 1213 silver badges14 bronze badges 4
  • I have noticed that in the Login ponent you call this.$store.dispatch('signUserIn') but in your vuex store in the actions there is not such an action. The only action is onUserLogin . You should make an action called signUserIn – gijoe Commented Sep 12, 2018 at 19:07
  • Good attention, but it still doesn't work. I pushed again with correct name of action. – Bartlomiej Mroczek Commented Sep 12, 2018 at 19:24
  • Can you please make also an update in action signUserIn(payload) to signUserIn(context,payload) and remove methods attribute in vuex store – gijoe Commented Sep 12, 2018 at 19:34
  • Hmm I do this, and it still doesn't work. If I good remember you should have permission to update 'help' branch. Fell free to do this. – Bartlomiej Mroczek Commented Sep 12, 2018 at 19:58
Add a ment  | 

1 Answer 1

Reset to default 4

Your store should be:

export default new Vuex.Store({

and not

export const store = new Vuex.Store({

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745067771a4609357.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信