简体   繁体   English

如何解决此错误类型“未捕获的TypeError:(...)不是函数”?

[英]How to resolve this error type 'Uncaught TypeError: (…) is not a function'?

I am aware of the another question like this on stackoverflow and have looked at it, but it doesn't answer/resolve my situation that I'm having from which the error has occurred. 我知道关于stackoverflow的另一个问题,并已经进行了研究,但是它不能回答/解决我所发生错误的情况。

I'm trying to make both scripts, embed.js (plugin) & more-content-arrow.js (my script) work properly on the page when the document loads. 我正在尝试使两个embed.js (插件)和more-content-arrow.js (我的脚本)脚本在文档加载时在页面上正常工作。 When and if I remove either script, one or the other will work but not both scripts together. 当我删除其中一个脚本时,一个或另一个将可以工作,但两个脚本不能一起工作。 When the page finishes loading first, it will load the more-content-arrow.js properly, then when it is trigged again by a scrolling event, it will give off this error message in the console browser: 页面首先完成加载后,它将正确加载more-content-arrow.js ,然后当滚动事件再次触发该页面时,它将在控制台浏览器中发出以下错误消息:

VM249 embed.js:2 Uncaught TypeError: ((fe.event.special[s.origType] || (intermediate value)).handle || s.handler).apply is not a function
    at dispatch (VM249 embed.js:2)
    at m.handle (VM249 embed.js:2)

I tried to resolve it by adding a jQuery.noConflict(); 我试图通过添加jQuery.noConflict();来解决它jQuery.noConflict(); , but that doesn't work as I assume it could be a conflict between the two scripts. ,但这不起作用,因为我认为这可能是两个脚本之间的冲突。 The only way I found out to get rid of the error message is removing one of the two scripts file or removing $.getScript(...) , but I don't want to do that. 我发现摆脱错误消息的唯一方法是删除两个脚本文件之一或删除$.getScript(...) ,但是我不想这样做。 I want to be able to keep both scripts running properly in the page. 我希望能够使两个脚本在页面中正常运行。

JS: JS:

$(document).ready(function(){
  //jQuery.noConflict();
  $.getScript("more-content-arrow.js", function(){
    alert("arrow script loaded and executed.");
  });
});

I recreated a jsfiddle with the uncaught type error here: 我在这里用未捕获的类型错误重新创建了一个jsfiddle:

https://jsfiddle.net/wr6cc2ct/2/ https://jsfiddle.net/wr6cc2ct/2/

Your error appears it be in your more-content-arrow.js file, you were passing an integer as a third argument which is not a handler, here is the jquery doc for .on() 您的错误似乎出现在more-content-arrow.js文件中,您正在传递一个整数作为不是处理程序的第三个参数,这是.on()的jquery文档

$(window).on('scroll', function () {
    if (!footerIsVisible) {
        $('.bounce').fadeIn(300);
    }
}); // <--- removed integer here.

Update 更新

Alternatively, you can use event.stopPropagation(); 另外,您可以使用event.stopPropagation(); along with re-ordering the jquery.unevent.js script after the ember.js script. 以及在jquery.unevent.js脚本之后重新排序ember.js脚本。

$(window).on('scroll', function (e) {
    e.stopPropagation();
    if (!footerIsVisible) {
        $('.bounce').fadeIn(300);
    }
}, 800); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何解决Uncaught TypeError:对象不是函数? - How to resolve Uncaught TypeError: object is not a function? 如何解决Uncaught TypeError:undefined不是一个函数? - How to resolve Uncaught TypeError: undefined is not a function? 如何解决JavaScript中的“未捕获的TypeError:未定义不是函数”? - How to resolve “Uncaught TypeError: undefined is not a function” in javascript"? 错误错误:未捕获(承诺):TypeError:Promise.resolve 不是函数 TypeError:Promise.resolve 不是函数 - ERROR Error: Uncaught (in promise): TypeError: Promise.resolve is not a function TypeError: Promise.resolve is not a function 如何解决,Uncaught TypeError: videopath.addEventListener is not a function? - How to resolve, Uncaught TypeError: videopath.addEventListener is not a function? 未捕获的TypeError:drawImage类型错误 - Uncaught TypeError: Type error with drawImage JavaScript-未捕获的TypeError:类型错误 - JavaScript - Uncaught TypeError: Type error Highchart未捕获的错误-Uncaught TypeError:$(…).highcharts不是函数 - Highchart uncaught error - Uncaught TypeError: $(…).highcharts is not a function 未捕获的TypeError:$ .ajax(...)。error不是函数 - Uncaught TypeError: $.ajax(…).error is not a function 错误“未捕获的TypeError:$(...)。datetimepicker不是函数” - Error “Uncaught TypeError: $(…).datetimepicker is not a function”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM