如何解决vuex具有“挂接错误:'InternalError:太多递归'”有趣的是,我没有调用任何递归函数
这是我在Index.vue中安装的钩子,没有其他方法
mounted(){
for(let ref in this.$refs)
{
let ele = this.$refs[ref].$el; // storing DOM element into let
let offset = ele.offsetTop; //storing offset from a top of this DOM into let
this.$store.dispatch('scroll/set_vals',{ ref,ele,offset }) // calling action in the store and passing those variables
}
}
这是一个模块scroll
,主要用于声明变量并将有效负载存储在其中。对于我来说,一切看起来都很好,也很干净,但是我在控制台中显示“ [Vue警告]:挂接的钩子中出现错误:“内部错误:递归过多””错误。而且我什至不知道从哪里开始,因为您可以看到没有调用递归。并且知道我实际上找出哪一行代码给了我错误。我在下面注释掉了
export default {
namespaced: true,state: {
currentBlock: 'intro',blocks: {
greet: {
el: null,active: true,offset: 0
},interests: {
el: null,active: false,projects: {
el: null,contact: {
el: null,offset: 0
}
}
},mutations: {
set_offset(state,payload){
state.blocks[payload.ref].offset = payload.offset;
},set_ele(state,payload){
state.blocks[payload.ref].el = payload.ele; // This line is where I have ERROR!! I consoled logged and payload.ele has DOM element and nothing else. But if I comment error disappears
},},actions:{
set_vals({commit},payload){
let ref = payload.ref;
let ele = payload.ele;
let offset = payload.offset;
commit('set_offset',offset})
commit('set_ele',ele })
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。