js递归数据操作,非常复杂,无法解决。
1:因为和用的angular,输出传回时,需要满足后台要求的数据格式。在前台操作的时候,为了满足primeng的使用数据格式,导致数据格式不同,求大神帮忙写一下,已经耗费了一天时间。
2:这是我现在使用的数据,需要可以无限嵌套下去!
var arr = [ {"children": [
{
"children": [
{
"children": [
{
"children": [
{
"children": null,
"data": {
"data": {
"start": null,
"limit": null,
"orderCol": null,
"zdxmc": "五",
}
}
}
],
"data": {
"start": null,
"limit": null,
"orderCol": null,
"zdxmc": "四",
}
}
],
"data": {
"start": null,
"limit": null,
"orderCol": null,
"zdxmc": "三",
}
}
],
"data": {
"start": null,
"limit": null,
"orderCol": null,
"zdxmc": "er",
}
}
],
"data": {
"start": null,
"limit": null,
"orderCol": null,
"zdxmc": "一",
}
},
{
"children": [
{
"children": [
{
"children": [
{
"children": [
{
"children": null,
"data": {
"data": {
"start": null,
"limit": null,
"orderCol": null,
"zdxmc": "五",
}
}
}
],
"data": {
"start": null,
"limit": null,
"orderCol": null,
"zdxmc": "四",
}
}
],
"data": {
"start": null,
"limit": null,
"orderCol": null,
"zdxmc": "三",
}
}
],
"data": {
"start": null,
"limit": null,
"orderCol": null,
"zdxmc": "er",
}
}
],
"data": {
"start": null,
"limit": null,
"orderCol": null,
"zdxmc": "二",
}
}
];
这是后台需要的数据格式。
var resArr = [
{
"start": null,
"limit": null,
"orderCol": null,
"zdxmc": "一",
"children": [
{
"start": null,
"limit": null,
"orderCol": null,
"zdxmc": "er",
"children": [
{
"start": null,
"limit": null,
"orderCol": null,
"zdxmc": "三",
"children": [
{
"start": null,
"limit": null,
"orderCol": null,
"zdxmc": "四",
"children": [
{
"data": {
"start": null,
"limit": null,
"orderCol": null,
"zdxmc": "五",
},
"children": null
}
]
}
]
}
]
}
]
},
{
"start": null,
"limit": null,
"orderCol": null,
"zdxmc": "二",
"children": [
{
"start": null,
"limit": null,
"orderCol": null,
"zdxmc": "er",
"children": [
{
"start": null,
"limit": null,
"orderCol": null,
"zdxmc": "三",
"children": [
{
"start": null,
"limit": null,
"orderCol": null,
"zdxmc": "四",
"children": [
{
"data": {
"start": null,
"limit": null,
"orderCol": null,
"zdxmc": "五",
},
"children": null
}
]
}
]
}
]
}
]
}
];
3:搞了一天了,还是没有解决掉,跪求帮忙。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
测试了一下应该可以。