2020-09-04 js 遍历树结构 给对应叶子节点插值

2020-09-04  本文已影响0人  一只鱼_d589

// treeData 是获取到的树结构 realTimeRect为要插入的值
`
getNewTreeData(treeData) {
let keyArray = Object.keys(this.realTimeRect)
keyArray.forEach(item => {
let that = this;
that.breadthQuery(treeData, item, that.realTimeRect[item]);
})
}

    breadthQuery(tree, id, rectsData) {
        var stark = [];
        stark = stark.concat(tree);
        while(stark.length) {
            var temp = stark.shift();
            if(temp.children) {
                stark = stark.concat(temp.children);
            }
            if(temp.id == parseInt(id)) {
                rectsData.forEach((item, index) => {
                    if(item) {
                        temp.rects[index].intervalData = item.intervalData 
                    }
                });
                debugger;
                return tree;
            }
        }
    },

`

上一篇 下一篇

猜你喜欢

热点阅读