数据表:未捕获的类型错误:无法读取未定义的属性“默认值" [英] DataTables: Uncaught TypeError: Cannot read property 'defaults' of undefined
本文介绍了数据表:未捕获的类型错误:无法读取未定义的属性“默认值"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
将 Bootstrap 集成用于数据表时,我在控制台中看到以下错误:
When using the Bootstrap integration for DataTables, I see the following error in the console:
Uncaught TypeError: Cannot read property 'defaults' of undefined (dataTables.bootstrap.js:20)
这会导致分页控件上没有样式.
This causes the pagination controls to not have styles on them.
可以看到在工厂初始化中,需要运行如下代码:
I can see that in the factory initialization, the following code needs to run:
factory( jQuery, jQuery.fn.dataTable );
然而,jQuery.fn.dataTable
正在返回 undefined
.
推荐答案
问题是 dataTable
在您调用此方法时未定义.
The problem is that dataTable
is not defined at the point you are calling this method.
确保以正确的顺序加载 .js
文件:
Ensure that you are loading the .js
files in the correct order:
<script src="/Scripts/jquery.dataTables.js"></script>
<script src="/Scripts/dataTables.bootstrap.js"></script>
这篇关于数据表:未捕获的类型错误:无法读取未定义的属性“默认值"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文