<body>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</body>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script>
var data = [
{name: "Locke", number: 4},
{name: "Reyes", number: 8},
{name: "Ford", number: 15},
{name: "Jarrah", number: 16},
{name: "Shephard", number: 31},
{name: "Kwon", number: 34}
];
d3.selectAll("div")
.data(data, function(d) { console.log(d);return d ? d.name : this.id; })
.text(function(d) { return d.number; });
</script>
</body>
如上面的代码,得到的网页是空白的那个键值的function一直用不了