当我刚刚初始化它的高度时,我得到了这个cannot read property 'offsetHeight' of null
。
这是我的代码:
d3.select("#container")
.style("height", "100%")
.style("width", "100%")
.style("position", "relative")
.style("bottom", 0);
var width = document.getElementById("#container").offsetWidth,
height = document.getElementById("#container").offsetHeight,
radius = (Math.min(width, height) / 1.5);
使用document.getElementById()
时,不必在 id 前显式键入#
。