$('#table')。bootstrapTable不是函数

问题描述 投票:0回答:1

从bootstrap-table v。1.14.2更新到bootstrap-table v。1.15.2后,出现此错误

Uncaught TypeError: $('#table').bootstrapTable is not a function

注意:

我发现问题是bootstrapTable函数并未最终出现在jQuery元素原型中。我查看了node_modules / bootstrap-table / dist / bootstrap-table.js中的dist文件夹,并看到了它(对于v 1.15.2):

(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery')) :
    typeof define === 'function' && define.amd ? define(['jquery'], factory) :
    (global = global || self, global.BootstrapTable = factory(global.jQuery));
}(this, function ($) {
    // do some stuff
    $.fn.bootstrapTable = function (option, ...args) { ... }
    // do some other stuff
 }));

而对于v 1.14.2版本,它看起来像这样:

(function (global, factory) {
  if (typeof define === "function" && define.amd) { define([], factory); }
  else if (typeof exports !== "undefined") { factory(); }
  else {
    var mod = {
      exports: {}
    };
    factory();
    global.bootstrapTable = mod.exports;
  }
})(this, function () {
    // do some stuff
    $.fn.bootstrapTable = function (option, ...args) { ... }
    // do some other stuff
});

关键是在1.15.2版中。我们需要新的jQuery实例,所以当我使用$('#table').bootstrapTable时,$bootstrap-table.js中的形式不同,但在1.14.2中,我们使用全局$变量,所以当我使用$('#table').bootstrapTable时,$bootstrap-table.js中的对象相同,因此我们具有bootstrapTable函数。我可以以某种方式解决此问题吗?

javascript jquery reactjs twitter-bootstrap-3 bootstrap-table
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.