VueJS: Cannot read property 'dispatch' of undefined

送分小仙女□ 提交于 2020-01-24 21:07:47

问题


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 component with button which should call dispatch
Login component.

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.


回答1:


Your store should be:

export default new Vuex.Store({

and not

export const store = new Vuex.Store({



来源:https://stackoverflow.com/questions/52301772/vuejs-cannot-read-property-dispatch-of-undefined

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!