在写vuex 里的getters时,报这个错误。
Error in mounted hook: "TypeError: handlers[i].call is not a function"
在网上查一下,说是可能是钩子函数写错的原因,看了一下真是的,是想在计算属性里调用vuex,结果写成下面的钩子函数了
mounted: {
count() {
return this.$store.getters.getCount;
}
},
改成下面这样,就ok了。
computed: {
count() {
return this.$store.getters.getCount;
}
},
本文解决了一个在Vue项目中使用Vuex时常见的错误:TypeError: handlers[i].call is not a function。错误源于在mounted钩子中不当调用Vuex的Getter。正确的做法是在计算属性(computed)中进行调用。
6916

被折叠的 条评论
为什么被折叠?



