【问题标题】:Error in jquery datatablesjquery数据表中的错误
【发布时间】:2016-03-17 17:42:00
【问题描述】:

我的 .html 代码:

<table id="unique_id_table">
    <tr>
        <th>Base Url</th>
        <th>Statistics Ur</th>
        <th>Options</th>
    </tr>
    <tr>
        <td>1</td>
        <td>1</td>
        <td>1</td>
    </tr>
</table>

我的js代码:

    $(document).ready(function () {
        $('#unique_id_table').DataTable({
        });
    })

错误

Uncaught TypeError: Cannot read property 'mData' of undefined

为什么?

我从我的另一个页面复制了它,一切正常

【问题讨论】:

    标签: javascript jquery html datatables


    【解决方案1】:

    您应该知道的第一件事是如何在 Google 上搜索某些内容。这样的错误很容易找到有同样问题的人。

    据此:http://datatables.net/forums/discussion/20273/uncaught-typeerror-cannot-read-property-mdata-of-undefined

    您缺少theadtbody 标签。似乎它们是必需的。

    <table id="unique_id_table">
        <thead>
            <tr>
                <th>Base Url</th>
                <th>Statistics Ur</th>
                <th>Options</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>1</td>
                <td>1</td>
                <td>1</td>
            </tr>
        </tbody>
    </table>
    

    来自official documentation with the same prerequisites

    【讨论】:

    • 不,我有thead和tbody
    • 不符合您在 OP 中的代码。我没有看到他们。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-02-18
    • 1970-01-01
    • 1970-01-01
    • 2014-12-01
    • 1970-01-01
    • 2011-03-02
    • 1970-01-01
    相关资源
    最近更新 更多