DataTables: Uncaught TypeError: Cannot read property 'defaults' of undefined

前端 未结 4 1550
逝去的感伤
逝去的感伤 2020-12-08 03:54

When using the Bootstrap integration for DataTables, I see the following error in the console:

Uncaught TypeError: Cannot read property \'defaults\' of undefined (         


        
4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-08 04:30

    var datatable_jquery_script = document.createElement("script");
    datatable_jquery_script.src = "vendor/datatables/jquery.dataTables.min.js";
    document.body.appendChild(datatable_jquery_script);
    setTimeout(function(){
        var datatable_bootstrap_script = document.createElement("script");
        datatable_bootstrap_script.src = "vendor/datatables/dataTables.bootstrap4.min.js";
        document.body.appendChild(datatable_bootstrap_script);
    },100);
    

    I used setTimeOut to make sure datatables.min.js loads first. I inspected the waterfall loading of each, bootstrap4.min.js always loads first.

提交回复
热议问题