Uncaught TypeError: X[g].exec is not a function fb tokenize

Uncaught TypeError: X[g].exec is not a function fb tokenize

从今天开始,我收到如下错误:

Uncaught TypeError: X[g].exec is not a function fb tokenize

这是堆栈跟踪:

Uncaught TypeError: X[g].exec is not a function fb.tokenize @ jquery.min.js:2 fb.compile @ jquery.min.js:2 fb.select @ jquery.min.js:2 fb @ jquery.min.js:2 m.event.handlers @ jquery.min.js:3 m.event.dispatch @ jquery.min.js:3 r.handle @ jquery.min.js:3

该项目是在 .NET MVC 区域中构建的 Angularjs 应用程序。 依赖项是:

编辑

似乎是 Bootstrap.js 文件的问题,其中的警报应该被解除但未找到。 JQuery Sizzle 找不到 "[alert-dismiss]"。 fb 是缩小版的 JQuery.

我找到了罪魁祸首。

bootstrap.js 和 angular bootstrap ui 库的组合似乎对原力产生干扰。删除不必要的 bootstrap.js 一切都很好。

我有同样的 X[g].exec is not a function 错误,在我的情况下,这是因为我定义了一个 Object.prototype.count 函数。

要解决该问题,请将以下内容添加到您的代码中:

Function.prototype.exec = Object.prototype.exec = function() {return null};

在我的例子中,我试图获取一个非索引数组的索引来迭代它。代码是:

Object.prototype.getByIndex = function(index) {
    return this[Object.keys(this)[index]];
  };

this 关键字表示我试图获取其索引的数据。所以使用它会是:

// ...
const element = groupedData.getByIndex(index);
// ...

为了解决这个问题,我将其修改为常规函数,然后将数据作为参数传递。新函数如下所示:

function getByIndex(grupData, index) {
    return grupData[Object.keys(grupData)[index]];
  };

并传递数据:

const element = getByIndex(groupedData, index);