我正在尝试使用队列来确保在脚本继续之前完全加载我的文件。但是,当我加载我的json映射文件并尝试在函数中使用它们时,我收到错误。
var counties = svg.append("g")
.attr("id", "counties")
.attr("class", "Blues");
var states = svg.append("g")
.attr("id", "states");
queue()
.defer(d3.json, "county.json")
.defer(d3.json, "state.json")
.defer(d3.json, "Crashes.json")
.await(ready);
function ready(county, state, crashes) {
var countyFeatures = topojson.feature(county, county.objects.counties);
var stateFeatures = topojson.feature(state, state.objects.states);
/*
counties.selectAll("path")
.data(county.features)
.enter().append("path")
.attr("class", "q8-9")
.attr("d", path);
states.selectAll("path")
.data(state.features)
.enter().append("path")
.attr("d", path);
*/
}
错误为Uncaught TypeError: Cannot read property 'objects' of null
有人可以解释为什么在传入函数时它为空?而不是分别运行d3.json并使用
d3.json("URL", function(d) {var temp = topojson.feature(d, d.objects.counties;});
感谢。