我遇到了这样的问题,很长时间都无法解决。所以,有两个多维对象。我必须通过将这两个对象合并为一个对象来执行将这两个对象合并为一个最终对象的操作。问题是对象是多维的,我无法通过合并正确合并它们。通过这个链接你可以看到对象的数据,下面我将给出最终结果的视图。
[
{
text: 'A', children: [{
text: 'B', children: [{
text: 'C',
children: [
{text: 'B [43]', id: '43'},
{text: 'B [93]', id: '93'},
{text: 'B [11]', id: '11'},
]}
]}
]
},
{
text: 'D', children: [{
text: 'M', children: [{
text: 'N', children: [
{text: 'M [66]', id: '66'}
]}
]
}]
},
{
text: 'W', children: [
{
text: 'M', children: [{
text: 'K', children: [
{text: 'M [48]', id: '48'},
{text: 'M [58]', id: '58'}
]
}]
}, {
text: 'T', children: [{
text: 'K', children: [{text: 'S [78]', id: '78'}]
}]
}
]
}
];
无论如何,我添加源对象:
const data_1 = [{
text: 'A', children: [{
text: 'B', children: [{
text: 'C',
children: [
{text: 'B [43]', id: '43'},
{text: 'B [11]', id: '11'},
]}
]}
]
},
{
text: 'W', children: [
{
text: 'M', children: [{
text: 'K', children: [{text: 'M [48]', id: '48'}]
}]
}, {
text: 'T', children: [{
text: 'K', children: [{text: 'S [78]', id: '78'}]
}]
}
]
}
];
const data_2 = [{
text: 'A', children: [{
text: 'B', children: [{
text: 'C',
children: [
{text: 'B [93]', id: '93'},
{text: 'B [11]', id: '11'},
]}
]}
]
},
{
text: 'D', children: [{
text: 'M', children: [{
text: 'N', children: [
{text: 'M [66]', id: '66'}
]}
]
}]
},
在这里,所有元素的联合发生在它们出现在一个对象中而在另一个对象中不存在的地方。
我知道这项任务并不容易,它可能无法以这种格式获得解决方案,但我恳求您不要路过,至少提供建议、分享经验、提供替代方案、提供类似信息等。解决这个问题对我来说非常重要,我将非常感谢任何帮助,意思是建议,有用的信息,当然还有解决方案。
慕码人8056858
摇曳的蔷薇
相关分类