【问题标题】:No select2/compat/inputData没有 select2/compat/inputData
【发布时间】:2018-07-26 04:06:42
【问题描述】:

我将 Select2JS 4.0.5 与 PHP 和 jQuery 3.2.1 一起使用。首先包含 jQuery,然后是 select2js,然后是其余的 JS 库。我的代码

if ($("#company").length > 0){   // The code below works with typeaheadJS
$('#company').select2()({
source: function (query, syncResults, asyncResults) {
        $.ajax({
            url: "common/search.php",
            data: 'query=' + query,
            dataType: "json",
            type: "POST",
            success: function (data) {
                asyncResults($.map(data, function (item) {
                    return item;
                }));
            }
        });
    }
});
} 

我不断收到Error: No select2/compat/inputData

类似的问题说,如果我包含完整版本,则此错误将得到修复。如果我这样做,错误会变成

TypeError: $(...).select2(...) is not a function

【问题讨论】:

  • 同样的问题,你找到解决办法了吗?
  • @MickaelLeger 不,我切换到selectize.github.io/selectize.js
  • 好的,这很奇怪我有另一个项目,我在输入上使用 select2 没有问题,但我只是尝试将我的“输入”更改为“选择”,现在它可以工作了

标签: javascript jquery jquery-select2 jquery-select2-4


【解决方案1】:

input 标记更改为select 标记对我有用。

【讨论】:

    【解决方案2】:

    您需要包含完整版,select2.full.js 此版本支持输入类型,而不仅仅是选择。

    【讨论】:

      【解决方案3】:

      代替:

      import 'select2'
      

      我做到了:

      import 'select2/dist/js/select2.full'
      

      【讨论】:

        猜你喜欢
        • 2015-07-25
        • 1970-01-01
        • 2018-02-03
        • 1970-01-01
        • 1970-01-01
        • 2018-11-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多