我正在使用handsontable库来创建整洁的表。
我简直复制的教程,但控制台(web开发者控制台)给了我以下错误:Javascript Handsontable - 未捕获TypeError:无法读取undefined属性'insertBefore'
Uncaught TypeError: Cannot read property 'insertBefore' of undefined
handsontable.full.js:4471
我都联系起来了的.css和.js文件在<head>
标签文件正确。
我的JavaScript看起来像这样:
var data = [
["", "Ford", "Volvo", "Toyota", "Honda"],
["2016", 10, 11, 12, 13],
["2017", 20, 11, 14, 13],
["2018", 30, 15, 12, 13]
];
var container = document.getElementById('temp');
var hot = new Handsontable(container, {
data: data,
rowHeaders: true,
colHeaders: true,
dropdownMenu: true
});
HTML:
<div id="temp"></div>
在handsontable.full.js 4471线是
rootElement.insertBefore(this.container, rootElement.firstChild);
不显示表中,控制台中的错误是我所拥有的。
我的猜测是你正试图在页面存在之前阅读元素。要么调用onload代码,要么将代码放在页面上的元素后面。 – epascarello