Datatable Uncaught TypeError:无法读取未定义的属性“mData”

时间:2018-05-03 07:13:21

标签: javascript datatable html-table

我正在使用 datatable 在Javascript中通过数组形成表格:

<table class="table display" id='contest__table' style="width:100%">
</table>

var dataSet = [
        [ "player1", "1", "0", "upgrade level "],
        [ "player1", "2", "0", "upgrade level "],
        [ "player1", "3", "0", "upgrade level "],
        [ "player1", "4", "0", "upgrade level "],
        [ "player1", "5", "0", "upgrade level "],
        [ "player1", "6", "0", "upgrade level "],
        [ "player1", "7", "0", "upgrade level "],
        [ "player1", "8", "0", "upgrade level "],
        [ "player1", "9", "0", "upgrade level "],
        [ "player1", "10", "0", "upgrade level "]
    ];

    $(document).ready(function() {
        $('#contest__table').DataTable( {
               data: dataSet,
                    columns: [
                       { title: "Player" },
                       { title: "column1" },
                       { title: "column2" },
                       { title: "column3" }
                     ]
        } );
    } );

Codepen

奇怪的是它在codepen中运行良好,但它在我的网站上不起作用。

它始终返回“无法读取未定义的属性'mData'”。即使我使用完全相同的代码&amp;库。我的表格中没有任何内容与我的代码集相同。

如果您有这方面的经验,请给我建议。

0 个答案:

没有答案