DataTables + RequireJS:无法读取undefined的属性’defaults’

我已经下载了DataTables的完整软件包及其所有模块,因为它无法通过CDN URL访问:

https://www.datatables.net/download/ (所有选项均已选中)

我正在尝试使用RequireJS运行它,整个DataTables包中使用相同的依赖系统,所以它不应该失败。

JSFiddle(为JSFiddle编辑): http : //jsfiddle.net/42ucpwee/1/

我的配置导致此错误:

 datatables.js:93165 Uncaught TypeError: Cannot read property 'defaults' of undefined 

datatables.js:93161-93171:

 var DataTable = $.fn.dataTable; /* Set the defaults for DataTables initialisation */ $.extend( true, DataTable.defaults, { dom: "<'row'>" + "<'row'>" + "<'row'>", renderer: 'bootstrap' } ); 

造成这个错误的原因是什么,我错过了什么或者我的配置错了吗?

的script.js:

 define(['jquery','datatables.net'], function($) { $('#example').DataTable(); }); 

main.js:

 requirejs.config({ baseUrl: "lib", paths: { 'jquery': '//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min', 'bootstrap': '//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min', 'datatables.net': 'DataTables/datatables', 'script': '../js/script' }, shim: { 'bootstrap': { deps: ['jquery'] }, 'jquery': { exports: '$' }, 'datatables.net': { deps: ['bootstrap','jquery'] }, 'script': { deps: ['jquery','datatables.net'] } } }); requirejs(['script']); 

index.html的:

        
Name Position
Tiger Nixon System Architect

一个可接受的答案就是下载单个模块(而不是单个文件选项)并使用以下脚本,它似乎比一次包括所有问题引起的问题更少:

http://jsfiddle.net/42ucpwee/2/

 requirejs.config({ appDir: ".", baseUrl: "js", paths: { 'jquery': '//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min', 'bootstrap': '//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min', 'datatables' : 'jquery.dataTables.min', 'datatables-bootstrap' : 'dataTables.bootstrap', }, shim : { 'jquery' : { exports : 'jquery' }, 'bootstrap' : { deps : [ 'jquery' ], exports : 'Bootstrap' }, 'datatables' : [ 'jquery' ], 'datatables-bootstrap' : [ 'datatables' ], } }); require([ 'jquery', 'datatables-bootstrap' ], function ($) { $('#example').DataTable(); });