Uncaught Error: [vuex] getters should be function but “getters.default” is {}

Multi tool use
Multi tool use


Uncaught Error: [vuex] getters should be function but “getters.default” is {}



I recently build my VUE project for production using NPM, however in the console i get the following error. Does anyone have any idea why vuex is complaining ? npm 3.10 , node.js 8.11,


Uncaught Error: [vuex] getters should be function but "getters.default" is {}.
at assert (vuex.esm.js:97)
at vuex.esm.js:271
at vuex.esm.js:85
at Array.forEach (<anonymous>)
at forEachValue (vuex.esm.js:85)
at vuex.esm.js:270
at Array.forEach (<anonymous>)
at assertRawModule (vuex.esm.js:265)
at ModuleCollection.register (vuex.esm.js:191)
at new ModuleCollection (vuex.esm.js:165)



thank you
Tonathiu




1 Answer
1



I assume you have a function(getter) inside getters of vuex and you are trying to call it using something like


store.getters.default()



Which is a wrong way to do so, and you will get some errors log like that.



So the correct way is to use vuex's mapGetters inside the computed property of the vue component. which would look something like this in the code.


import { mapGetters } from 'vuex'
...
...
computed:{
...mapGetters(['default'])
},
...
...



And then try calling default getter using this(vm instance) like


this.default()



That's all it should work now.



I hope it helps.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

dMREJhnmBSG,5sOZOSi0gy6B SFsLb1xcGsld8hP5H,acOyn
3 8sr7GZ,i8W0iFSkyoao6wJ2ydIampxYGO mvTo 3P GMb6G 2QQCF KtfzjU,iD9,wjo2WMhWnTQi

Popular posts from this blog

Delphi Android file open failure with API 26

.

Amasya