javascript jQuery DataTables 错误 - TypeError:无法读取未定义的属性“fnInit”

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

jQuery DataTables error - TypeError: Cannot read property 'fnInit' of undefined

javascriptjqueryhtmldatatables

提问by Wizard

I'm getting this error:

我收到此错误:

Uncaught TypeError: Cannot read property 'fnInit' of undefined

未捕获的类型错误:无法读取未定义的属性“ fnInit

jquery.dataTables.js:2872

jquery.dataTables.js:2872

DataTable.ext.oPagination[ oSettings.sPaginationType ].fnInit( oSettings, nPaginate, 
                function( oSettings ) {
                    _fnCalculateEnd( oSettings );
                    _fnDraw( oSettings );
                }
            );

Table is placed properly, I think, that problem is not in HTML.

表格放置正确,我认为,问题不在 HTML 中。

回答by Gyrocode.com

CAUSE

原因

It seems that the problem is that you used not supported value for sPaginationTypeor pagingTypeoption.

似乎问题在于您使用了不支持的值sPaginationTypepagingType选项。

SOLUTION

解决方案

DataTables 1.10

数据表 1.10

Option pagingTypesupports the following values by default:

OptionpagingType默认支持以下值:

  • numbers- Page number buttons only (1.10.8+)
  • simple- 'Previous' and 'Next' buttons only
  • simple_numbers- 'Previous' and 'Next' buttons, plus page numbers
  • full- 'First', 'Previous', 'Next' and 'Last' buttons
  • full_numbers- 'First', 'Previous', 'Next' and 'Last' buttons, plus page numbers
  • numbers- 仅限页码按钮 (1.10.8+)
  • simple- 仅“上一个”和“下一个”按钮
  • simple_numbers- “上一个”和“下一个”按钮,以及页码
  • full- “第一个”、“上一个”、“下一个”和“最后一个”按钮
  • full_numbers-“第一个”、“上一个”、“下一个”和“最后一个”按钮,以及页码

DataTables 1.9

数据表 1.9

Option sPaginationTypesupports the following values by default:

OptionsPaginationType默认支持以下值:

  • two_button- 'Previous' and 'Next'
  • full_numbers- 'First', 'Previous', 'Next' and 'Last' buttons, plus page numbers
  • two_button- “上一个”和“下一个”
  • full_numbers-“第一个”、“上一个”、“下一个”和“最后一个”按钮,以及页码