treegrid报错 Uncaught TypeError: Cannot read property 'length' of undefined

提问 未结 1 6931
悬赏:20飞吻
我做了个treegrid用作菜单的管理,一切都是那么的顺利就显示出来并且可以用了,然后意外出现了。。。。我在做子节点增加的时候,突然显示错误,我怎么看树形的结构都没问题,就是显示不出来,报错:Uncaught TypeError: Cannot read property 'length' of undefined,如下



json如下:
[
{
"id":"1",
"name":"系统设置",
"level":1,
"children":[
{
"id":"1",
"name":"菜单管理",
"type":"1",
"iswhite":"0",
"level":2,
"children":[
{
"id":"2",
"name":"菜单管理",
"parentid":"1",
"iswhite":"0",
"level":3,
"children":[
{
"id":"3",
"name":"菜单列表",
"parentid":"2",
"iswhite":"0",
"level":4
},
{
"id":"4",
"name":"菜单添加",
"parentid":"2",
"iswhite":"0",
"level":4
},
{
"id":"5",
"name":"菜单删除",
"parentid":"2",
"iswhite":"0",
"level":4
},
{
"id":"6",
"name":"菜单白名单",
"parentid":"2",
"iswhite":"0",
"level":4
}
]
}
]
}
]
},
{
"id":"6",
"name":"测试大1",
"level":1,
"children":[
{
"id":"18",
"name":"测试中11",
"type":"6",
"iswhite":"0",
"level":2,
"children":[

]
}
]
},
{
"id":"2",
"name":"看板",
"level":1,
"children":[
{
"id":"14",
"name":"测试1",
"type":"2",
"iswhite":"0",
"level":2,
"children":[
{
"id":"15",
"name":"看看",
"parentid":"14",
"iswhite":"0",
"level":3,
"children":[

]
}
]
}
]
}
]
试验发现只要我把
{
"id":"18",
"name":"测试中11",
"type":"6",
"iswhite":"0",
"level":2,
"children":[

]
}
这段删了就可以显示了,完全不明白为什么,求大神指导
回帖
回帖须知