我一直在处理一些旧的 jsp 页面,并试图将 jQuery 引入其中。然而,这是我在页面上开始使用 jQuery 时得到的结果:
base.js:249 Uncaught TypeError: f is not a function
所以很明显,我们遗留的 base.js 和 jQuery 之间存在冲突。下面是导致问题的 base.js 中的代码片段:
Object.prototype.each = function (f) {
for (var n = 0; n < this.length; n++) {
f (this[n],n); // This is line 249
}
return this;
};
坏消息是我不能轻易地将这个库从页面中重构出来,因为还有一些其他的 JavaScript 库在页面中使用它。
有什么我可以做的吗?谢谢!