【问题标题】:DataTable is not a function, what's wrong?DataTable 不是函数,怎么了?
【发布时间】:2020-03-09 09:21:04
【问题描述】:

我在 laravel 项目中使用数据表。但是表格没有渲染。它显示错误:

Uncaught TypeError: $(...).DataTable is not a function
    at HTMLDocument.<anonymous> (dashboard:147)
    at l (datatables.min.js:14)
    at c (datatables.min.js:14)

我已经按照以下顺序包含了 jQuery、js 和 css

  • jQuery
  • 数据表js
  • 数据表css

还有什么可能导致问题?

【问题讨论】:

    标签: laravel yajra-datatable


    【解决方案1】:

    确保在首选 dataTable.js 文件之前加载 jquery.js。

    <script type="text/javascript" src="~/Scripts/jquery.js"></script>
    <script type="text/javascript" src="~/Scripts/data-table/jquery.dataTables.js"></script>
    
     <script>$(document).ready(function () {
        $.noConflict();
        var table = $('# your selector').DataTable();
    });</script>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-02-05
      • 2016-10-07
      • 1970-01-01
      • 2022-08-22
      • 2016-04-09
      • 2015-08-19
      • 2015-09-22
      相关资源
      最近更新 更多