我正在尝试从d3 v3切换到v4进行树布局,并且在使用root.descnedants函数时遇到错误,因为它不是函数。
我正在关注https://www.developer.com/lang/jscript/creating-a-tree-diagram-with-d3.js.html
上的基本教程var data={
"name":"A",
"children":[
{
"name":"B",
"children":[
{
"name":"C"
},
{
"name":"E"
}
]
},
{
"name":"P",
"children":[
{
"name":"Q"
},
{
"name":"R"
}
]
}
]
};
var treelayout = d3.tree().size([500, 500]);
var nodes = d3.hierarchy(data);
nodes = treelayout(nodes,d => d.children);
console.log(nodes);
console.log(nodes.descendents());
未捕获的TypeError:nodes.descendents不是函数 在test2_d3.html:42 (匿名)@ test2_d3.html:42