我尝试运行快速入门链接(Quick Start)中提到的示例。已通过Git集线器下载所有文件。当尝试运行快速入门中提到的示例时,出现以下错误"cannot read property 'insertBefore‘of null - handsontable.full.js:3714“。请帮助我运行基本示例。
使用的版本- v0.16.1
代码:
<!DOCTYPE html>
<html>
<head>
<script src="dist/handsontable.full.js"></script>
<link rel="stylesheet" media="screen" href="dist/handsontable.full.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
var data = [
["", "Ford", "Volvo", "Toyota", "Honda"],
["2014", 10, 11, 12, 13],
["2015", 20, 11, 14, 13],
["2016", 30, 15, 12, 13]
];
var container = document.getElementById('example');
var hot = new Handsontable(container, {
data: data,
minSpareRows: 1,
rowHeaders: true,
colHeaders: true,
contextMenu: true
});
</script>
<style>
body {
background-color: white;
margin: 20px;
}
h2 {
margin: 20px 0;
}
</style>
</head>
<body>
<h2>Default Handsontable Demo</h2>
<div id="example"></div>
</body>
发布于 2015-08-04 01:59:12
试着把3个脚本节点放在你的身体里,而不是头部。这感觉像是你如何加载模块的问题。
发布于 2017-07-11 02:20:53
我也犯了同样的错误,至少对我来说,错误的发生是因为我使用了一个不存在的元素ID。
在这一行中:
var container = document.getElementById("example");确保div的ID具有相同的名称。在本例中,它是"example":
<div id="example"></div>如果加载Handsontable时容器为undefined,则会显示此错误消息。
发布于 2020-07-31 14:10:01
有时甚至空间都会导致这个错误。
// example
var container = document.querySelector('header .container');
//in this i made mistake of space between header and container class so he can't find and show me error
var container = document.querySelector('header .container');https://stackoverflow.com/questions/31780326
复制相似问题