0
這是從HTML文件我的代碼腳本標記錯誤鏈接沒有定義
var links;
d3.json("sample.json",function(json){links=json;});
var inputlinks=[];
var nodes = {};
inputlinks.push(links);
// Compute the distinct nodes from the links.
links.forEach(function(link) {
link.source = nodes[link.source] || (nodes[link.source] = {name: link.source, type:link.type});
link.target = nodes[link.target] || (nodes[link.target] = {name: link.target, type:link.typeKBP});
});
在這段代碼我得到一個錯誤
TypeError: links is undefined
links.forEach(function(link)
'd3.json'是一個異步調用嗎? –