未捕获的TypeError:$(...)。dataTables不是函数(...)

时间:2016-11-29 16:35:27

标签: firebase datatables

         数据库管理站点

    <script type="text/javascript" src="jQuery/jquery.min.js"> </script>
    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css"/>
    <script type="text/javascript" src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"> </script>

    <script src="dialog-polyfill.js"></script>
    <link rel="stylesheet" type="text/css" href="dialog-polyfill.css" />
    <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
    <link rel="stylesheet" href="https://code.getmdl.io/1.2.1/material.green-cyan.min.css" />

    <script defer src="https://code.getmdl.io/1.2.1/material.min.js"></script>
    <script src="https://www.gstatic.com/firebasejs/3.6.1/firebase.js"></script>
    <script src="https://www.gstatic.com/firebasejs/live/3.1/firebase.js"></script>

    <link rel = "stylesheet" href = "style.css" />

    <script type = "text/javascript">
      $(document).ready(function () {
        $('#dbTable').dataTables();
      });
    </script>

  </head>
  <body>
     <table id = "dbTable"class="display mdl-data-table mdl-js-data-table mdl-shadow--2dp" cellspacing = "0" width = "100">
    <thead>
      <tr>
        <th class="mdl-data-table__cell--non-numeric">Email</th>
        <th>First Name </th>
        <th>Last Name </th>
        <th>Number </th>
      </tr>
    </thead>
    <tbody id = "tableBodyObject" class="tableBodyClass">
      <!-- Table DATA //-->
    </tbody>
  </table>

    <script type="text/javascript" src = "index1.js"></script>

</body>

所以当我运行代码时 它显示在控制台中

Uncaught TypeError: $(...).dataTables is not a function(…)

我使用Firebase使用Firebase数据库创建表格,我尝试使用数据表,但它无法正常工作

1 个答案:

答案 0 :(得分:0)

应使用dataTable()(DataTables 1.9+)或DataTable()(DataTables 1.10+)进行初始化。有关详细信息,请参阅Initializing DataTables

idclass属性之间也缺少空格,应该是:

<table id="dbTable" class="display mdl-data-table mdl-js-data-table mdl-shadow--2dp" cellspacing="0" width="100">