首页 > 解决方案 > 数据表 - 未捕获的类型错误:ba 未定义

问题描述

我遇到的错误是:

"Uncaught TypeError: ba is undefined"
"https://cdn.datatables.net/v/dt/dt-1.10.22/b-1.6.5/b-print-1.6.5/r-2.2.6/datatables.min.js:119"

没有显示其他错误。我将 Jquery 放在列表的首位,并检查了所有路径是否正常。我还从数据表站点获得了我认为最合适的链接。

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Ajax Filter table</title>    
    <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>

    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/dt-1.10.22/b-1.6.5/b-print-1.6.5/r-2.2.6/datatables.min.css"/>
    <script type="text/javascript" src="https://cdn.datatables.net/v/dt/dt-1.10.22/b-1.6.5/b-print-1.6.5/r-2.2.6/datatables.min.js"></script>

    <script>
        $(document).ready(function(){
            $('#table').DataTable();
        })
    </script>

</head>
<body>
    <div class="container">
            <table class="table table-striped" id="table">
                <tr>
                    <th>one</th>
                    <th>two</th>
                    <th>three</th>
                    <th>four</th>
                </tr>
                <tr>
                    <td>one</td>
                    <td>two</td>
                    <td>three</td>
                    <td>four</td>
                </tr>                
            </table>
    </div>
</body>
</html>

标签: javascriptjquerydatatables

解决方案


解决方案是以数据表喜欢的方式构建表。他们的主页上没有任何内容,他们告诉您这只是导入 2 个脚本文件的情况。但它们要求您使用 thead 和 tbody 元素。没有这个,它只会翻倒,错误对诊断毫无帮助!


推荐阅读