我正在使用某些数据表,并且不断出现以下错误。功能正常,但引导类不适用于此DataTable。
dataTables.bootstrap4.min.js:9 Uncaught TypeError: Cannot read property 'defaults' of undefined
at dataTables.bootstrap4.min.js:9
at dataTables.bootstrap4.min.js:8
at dataTables.bootstrap4.min.js:8
我正在按正确的顺序调用所有脚本文件...
还有其他原因吗?
<link href="~/Content/Custom/BootstrapDatatable/bootstrap.css" rel="stylesheet" />
<link href="~/Content/Custom/BootstrapDatatable/dataTables.bootstrap4.min.css" rel="stylesheet" />
<script src="~/Content/Custom/BootstrapDatatable/jquery-3.5.1.js"></script>
<script src="~/Content/Custom/BootstrapDatatable/jquery.dataTables.min.js" defer></script>
<script src="~/Content/Custom/BootstrapDatatable/dataTables.bootstrap4.min.js"></script>
在线链接:
https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.css
https://cdn.datatables.net/1.10.21/css/dataTables.bootstrap4.min.css
https://code.jquery.com/jquery-3.5.1.js
https://cdn.datatables.net/1.10.21/js/jquery.dataTables.min.js
https://cdn.datatables.net/1.10.21/js/dataTables.bootstrap4.min.js
通话:
<script type="text/javascript">
$(document).ready(function () {
$('#myTable').DataTable();
});
</script>
HTML:
我仅添加一行必需的HTML
<table id="myTable" class="table table-striped table-bordered" style="width:100%">