2017-08-20 47 views
1

我正在使用Handsontable v0.34.0并尝试使用requirejs 进行集成我的require配置是正确的,因为我可以看到像时刻,numbro和pikaday一样正常加载的所有文件。 但是当我运行调用下面的代码Handsontable v0.34.0不能与requirejs一起工作

require(['jquery', 'handsontable'], function ($, Handsontable) { 
    let container = document.getElementById('container'); 
    let hot = new Handsontable(container, { 
     data: dataSet, 
     width: 584, 
     height: 320, 
     colWidths: 47, 
     rowHeights: 23, 
     rowHeaders: true, 
     colHeaders: true, 
     renderAllRows: true 
    }); 
}); 

我得到错误

Uncaught TypeError: Handsontable is not a constructor 

强烈疑问,这已经是与在handsontable.js

回答

3

webpack代码转换^h andsontable到H andsontable in code and require -config解决了这个问题。我不必对分布式文件做任何改变。

require(['jquery', 'handsontable'], function ($, Handsontable) { 

require(['jquery', 'Handsontable'], function ($, Handsontable) {