Javascript Handsontable - Uncaught TypeError: Cannot read property 'insertBefore' of undefined
Javascript Handsontable - Uncaught TypeError: Cannot read property 'insertBefore' of undefined
我正在使用 handsontable 库来创建整洁的 tables。
我从字面上复制了教程,但控制台(Web 开发人员控制台)给了我以下错误:
Uncaught TypeError: Cannot read property 'insertBefore' of undefined
handsontable.full.js:4471
我 link .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);
没有显示table,控制台中的错误就是我所得到的。
看起来像你的
document.getElementById('temp');
return未定义。
确保在 Handsontable
构建时容器元素仍然存在。
您的 rootElement
引用未定义。请检查此变量在哪里定义以及分配给什么。
我正在使用 handsontable 库来创建整洁的 tables。
我从字面上复制了教程,但控制台(Web 开发人员控制台)给了我以下错误:
Uncaught TypeError: Cannot read property 'insertBefore' of undefined
handsontable.full.js:4471
我 link .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);
没有显示table,控制台中的错误就是我所得到的。
看起来像你的
document.getElementById('temp');
return未定义。
确保在 Handsontable
构建时容器元素仍然存在。
您的 rootElement
引用未定义。请检查此变量在哪里定义以及分配给什么。