Javascript Handsontable - 未捕获的TypeError:无法读取未定义的属性“insertBefore” [英] Javascript Handsontable - Uncaught TypeError: Cannot read property 'insertBefore' of undefined

查看:436
本文介绍了Javascript Handsontable - 未捕获的TypeError:无法读取未定义的属性“insertBefore”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用handsontable库来创建整齐的表。

我真的复制了教程但是控制台(web开发人员控制台)给了我以下错误:

I'm using the handsontable library for creating neat tables.
I literally copied the tutorial but the console (web developer console) gives me the following error:

Uncaught TypeError: Cannot read property 'insertBefore' of undefined            
handsontable.full.js:4471 

我在< head> 标签中正确链接了.css和.js文件。

I link both the .css and the .js file correctly in the <head> tags.

我的javascript看起来像这样:

My javascript looks like this:

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行是

Line 4471 in handsontable.full.js is

rootElement.insertBefore(this.container, rootElement.firstChild);

表格未显示,控制台中的错误是我所有的。

The table isn't displayed, the error in the console is all I've got.

推荐答案

看起来你的

document.getElementById('temp');

返回undefined。

return undefined.

确保当 Handsontable 正在构建时,容器元素仍然存在。

Make sure that the container element is still there when Handsontable is constructing.

这篇关于Javascript Handsontable - 未捕获的TypeError:无法读取未定义的属性“insertBefore”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆