javascript 无法读取 null 的属性“insertBefore” - handsontable.full.js:3714
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31780326/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
cannot read property 'insertBefore' of null - handsontable.full.js:3714
提问by Prakash_se7en
I tried to run the example mentioned in the Quick start link(Quick Start). Downloaded all files via Git hub. when trying to run the example mentioned in quick start getting the following error "cannot read property 'insertBefore' of null - handsontable.full.js:3714". Please help me running the basic example.
我尝试运行快速入门链接(快速入门)中提到的示例。通过 Git hub 下载所有文件。尝试运行快速入门中提到的示例时,出现以下错误“无法读取 null 的属性‘insertBefore’ - handsontable.full.js:3714”。请帮助我运行基本示例。
Version used - v0.16.1
使用的版本 - v0.16.1
Code:
代码:
<!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>
回答by ZekeDroid
Try putting your 3 script nodes in your body rather than in the head. It feels like an issue with how you're loading the modules.
尝试将您的 3 个脚本节点放在您的身体而不是头部。感觉就像你加载模块的方式有问题。
回答by Zanon
I had the same error and, at least for me, the error happened because I've used an element ID that doesn't exist.
我有同样的错误,至少对我来说,错误发生是因为我使用了一个不存在的元素 ID。
In this line:
在这一行:
var container = document.getElementById("example");
Make sure that ID of your div has the same name. In this case, it is "example":
确保您的 div 的 ID 具有相同的名称。在这种情况下,它是“示例”:
<div id="example"></div>
If container is undefined
when loading Handsontable, this error message will be displayed.
如果容器undefined
在加载 Handsontable 时,将显示此错误消息。