【问题标题】:Handsontable v0.34.0 not working with requirejsHandsontable v0.34.0 不适用于 requirejs
【发布时间】:2017-08-21 14:44:44
【问题描述】:

我正在使用 Handsontable v0.34.0 并尝试使用 requirejs 进行集成 我的要求配置是正确的,因为我可以看到所有文件都可以正常加载,例如 moment、numbro 和 pikaday。 但是当我运行以下代码的调用时

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 中的webpack 代码有关

【问题讨论】:

    标签: webpack requirejs handsontable


    【解决方案1】:

    在代码和 require-config 中将 handsontable 转换为 Handsontable 解决了这个问题。我不必对分发的文件进行任何更改。

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

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

    【讨论】:

      猜你喜欢
      • 2013-08-02
      • 2015-06-21
      • 2019-07-15
      • 1970-01-01
      • 2020-02-01
      • 2017-11-01
      • 2015-04-27
      • 2013-05-24
      • 1970-01-01
      相关资源
      最近更新 更多