数据表不能在空表上工作

时间:2018-05-08 04:46:16

标签: javascript jquery datatables

<table></table>

<script>

$(function () {
    $('table').each(function () {
        $(this).DataTable(
               {

                   stateSave: true,
                   "sDom": 'C<"clear">rfrtip',
                   "scrollCollapse": true,
                   "paging": true,
                   responsive: true
            });

    });

});

发生错误:

 Uncaught TypeError: Cannot read property 'aDataSort' of undefined<br/>
         at _fnSortFlatten (jquery.dataTables.js:5889)<br/>
         at _fnSortingClasses (jquery.dataTables.js:6227)<br/>
         at loadedInit (jquery.dataTables.js:1234)<br/>
         at loaded (jquery.dataTables.js:6341)<br/>
         at _fnLoadState (jquery.dataTables.js:6425)<br/>
         at HTMLTableElement.<anonymous> (jquery.dataTables.js:1329)<br/>
         at Function.each (jquery.min.js:2)<br/>
         at w.fn.init.each (jquery.min.js:2)<br/>
         at w.fn.init.DataTable [as dataTable] (jquery.dataTables.js:869)<br/>
         at w.fn.init.$.fn.DataTable (jquery.dataTables.js:15172)

我也试过

<table><thead></thead><tbody></tbody></table>

编辑: 如何修复此而不填写

0 个答案:

没有答案