我尝试使用heatmap.js库,在示例代码中,浏览器控制台获取错误 未捕获的TypeError:无法读取属性' style'为null 在362行 我没有触及示例代码,但它无法正常工作
<div id="heatmapContainerWrapper">
<div id="heatmapContainer">
</div>
</div>
<script src="/build/heatmap.js"></script>
<script>
window.onload = function() {
// create a heatmap instance
var heatmap = h337.create({
container: document.getElementById('heatmapContainer'),
maxOpacity: .6,
radius: 50,
blur: .90,
// backgroundColor with alpha so you can see through it
backgroundColor: 'rgba(0, 0, 58, 0.96)'
});
var heatmapContainer = document.getElementById('heatmapContainerWrapper');
heatmapContainer.onmousemove = heatmapContainer.ontouchmove = function(e) {
// we need preventDefault for the touchmove
e.preventDefault();
var x = e.layerX;
var y = e.layerY;
if (e.touches) {
x = e.touches[0].pageX;
y = e.touches[0].pageY;
}
heatmap.addData({ x: x, y: y, value: 1 });
};
heatmapContainer.onclick = function(e) {
var x = e.layerX;
var y = e.layerY;
heatmap.addData({ x: x, y: y, value: 1 });
};
};
</script>
感谢您的帮助。