我的 Json:
[{"id":1,"text":"ungrouped","icon":"/icons/Group_16x16.png",
"parent":0,"dashboard":null,"childrenList":null}]
我的jS:
// ajax demo
$('#ajax_topo').jstree({
'core' : {
'data' : {
'url' : './topology.json',
'data' : function (node) {
return { 'id' : node.id };
}
}
}
});
我的 HTML:
<h1>AJAX Topology demo</h1>
<div id="ajax_topo" class="demo"></div>
我明白了
Error : Uncaught TypeError: Cannot read property 'children' of undefined
最佳答案
这是一个 Json 数组。所以你必须对其应用索引。
将node.id
替换为node[0].id
$('#ajax_topo').jstree({
'core' : {
'data' : {
'url' : './topology.json',
'data' : function (node) {
return { 'id' : node[0].id };
}
}
}
});
关于javascript - json 值的 jstree 给出了一些错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32600994/