jQuery 未捕获的类型错误:无法设置未定义的属性“nTf”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40633005/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 17:15:12  来源:igfitidea点击:

Uncaught TypeError: Cannot set property 'nTf' of undefined

jquerydatatables

提问by VISHAL SINGH

I am getting console error "Uncaught TypeError: Cannot set property 'nTf' of undefined". I am using jquery Datatable.

我收到控制台错误“未捕获的类型错误:无法设置未定义的属性 'nTf'”。我正在使用 jquery 数据表。

回答by Munkhdelger Tumenbayar

Okey Let me just to be clear for everyone , tfoot > thmust be equal as your thead > th

好吧,让我为大家说清楚,tfoot > th必须和你一样thead > th

i just faced this kind of problem recently and trying to figure it out like couple mins so just make sure in the future someone maybe be faced it

我最近刚遇到这种问题,并试图像几分钟一样解决它,所以请确保将来有人可能会遇到它

回答by meh-uk

As per https://datatables.net/forums/discussion/22697/uncaught-typeerror-cannot-set-property-ntf-of-undefinedyou probably have more cells in the header and/or footer of your table defined in your html than you are getting back from the server.

根据https://datatables.net/forums/discussion/22697/uncaught-typeerror-cannot-set-property-ntf-of-undefined您可能在 html 中定义的表格的页眉和/或页脚中有更多单元格比你从服务器回来。

At least that's the issue I was having which gave me this error message.

至少这是我遇到的问题,它给了我这个错误消息。

回答by Sumit Kumar Gupta

Hi I had same problem but now I have fixed my problem. This problem occurs because there are more column in head tag than body tag. If you have same error then first check how many column in thead and tbody or tfoot .

嗨,我有同样的问题,但现在我已经解决了我的问题。出现此问题是因为 head 标签中的列多于 body 标签。如果您遇到相同的错误,请先检查 thead 和 tbody 或 tfoot 中有多少列。

回答by Adam

Also, this error occurred for me when the columns in my Datatables setup did not match the columns in my HTML.

此外,当我的数据表设置中的列与我的 HTML 中的列不匹配时,我也会发生此错误。

I fixed it by making sure they match.

我通过确保它们匹配来修复它。

(In the image below, they do not match, which caused the error.)

(在下图中,它们不匹配,从而导致了错误。)

enter image description here

在此处输入图片说明

回答by Amer Almoghrabi

In your table Check all colspan attribute values if its equal to the number of columns

在您的表中检查所有 colspan 属性值是否等于列数

回答by schenker

I ran into this problem too. All columns in tfoot matched thead. Just a simple step of clearing browser cache did the magic for me. Hope this helps someone.

我也遇到了这个问题。tfoot 中的所有列都匹配 thead。只需一个简单的清除浏览器缓存的步骤就为我带来了魔力。希望这可以帮助某人。