Javascript 未捕获类型错误:无法读取属性';类型';未使用d3.js定义的

Javascript 未捕获类型错误:无法读取属性';类型';未使用d3.js定义的,javascript,d3.js,Javascript,D3.js,我已经在这个问题上纠缠了好几个小时了,现在我无法解决这个问题 我一直在关注我自己的数据集 错误:未捕获类型错误:无法读取未定义的-topojson.v0.min.js:1的属性“type” <!DOCTYPE html> <head> <meta charset="utf-8"> <style> path { fill: #ccc; stroke: #fff; stroke-width: .5px; } path:hover {

我已经在这个问题上纠缠了好几个小时了,现在我无法解决这个问题

我一直在关注我自己的数据集

错误:未捕获类型错误:无法读取未定义的-topojson.v0.min.js:1的属性“type”

<!DOCTYPE html>
<head>
<meta charset="utf-8">
<style>

path {
  fill: #ccc;
  stroke: #fff;
  stroke-width: .5px;
}

path:hover {
  fill: red;
}

</style>
</head>
<body>
<script src="../static/js/d3.min.js"></script>
<script src="../static/js/topojson.v0.min.js"></script>
<script>


var width = 900,
    height = 900;

var path = d3.geo.path();

var svg = d3.select("body").append("svg")
    .attr("width", width)
    .attr("height", height);


d3.json("../static/json/newjerseymun.json", function(nj) {
  svg.append("path")
      .datum(topojson.object(nj, nj.objects.subunits))
      .attr("d", d3.geo.path().projection(d3.geo.mercator()));
});

</script>

</body>

路径{
填充:#ccc;
冲程:#fff;
笔划宽度:.5px;
}
路径:悬停{
填充物:红色;
}
可变宽度=900,
高度=900;
var path=d3.geo.path();
var svg=d3.选择(“正文”).追加(“svg”)
.attr(“宽度”,宽度)
.attr(“高度”,高度);
d3.json(“../static/json/newjerseymun.json”),函数(nj){
追加(“路径”)
.datum(topojson.object(nj,nj.objects.subunits))
.attr(“d”,d3.geo.path().projection(d3.geo.mercator());
});

下面是我的json文件的开头示例:

问题似乎出在文件
。/static/json/newjerseymun.json

您发布的
newjerseymin.json
段确实包含包含json对象的字段
objects
,但该对象中似乎没有
子单元
字段,至少在您发布的段中没有。因此,
ns.objects.subunits
将是
未定义的
,这将导致错误