[英]Don't add methods to the wrong prototype
我將jQuery與Electron應用程序一起使用,但始終會收到一個似乎與jQuery補間函數相對應的錯誤。
我正在通過標准節點require加載jQuery:
<script type="text/javascript">window.$ = window.jQuery = require('jquery');</script>
當我通過腳本src包含jQuery時,出現相同的錯誤(jQuery版本3.3.1)
例如,調用$("#loading-overlay").fadeOut(200);
原因:
Uncaught TypeError: (Animation.tweeners[prop] || []).concat is not a function
at createTween ([PATH]/node_modules/jquery/dist/jquery.js:6848)
at Object.defaultPrefilter ([PATH]/node_modules/jquery/dist/jquery.js:7021)
at Animation ([PATH]/node_modules/jquery/dist/jquery.js:7160)
at HTMLDivElement.doAnimation ([PATH]/node_modules/jquery/dist/jquery.js:7293)
at Function.dequeue ([PATH]/node_modules/jquery/dist/jquery.js:4376)
at HTMLDivElement.<anonymous> ([PATH]/node_modules/jquery/dist/jquery.js:4418)
at Function.each ([PATH]/node_modules/jquery/dist/jquery.js:354)
at jQuery.fn.init.each ([PATH]/node_modules/jquery/dist/jquery.js:189)
at jQuery.fn.init.queue ([PATH]/node_modules/jquery/dist/jquery.js:4411)
at jQuery.fn.init.animate ([PATH]/node_modules/jquery/dist/jquery.js:7304)
我在Electron(4.0版)中只有這個問題。 有誰知道這是由什么引起的?
好吧,這是我的愚蠢。 自動完成功能使我將方法“ each”添加到Object原型而不是我的自定義類...這顯然使jQuery感到困惑,因為它在Animation.tweeners中找到了屬性“ each”(因為它在所有Objects中都存在)。
但是我了解到,當遇到一個毫無意義的令人困惑的錯誤時,請檢查是否意外覆蓋了您不想更改的原型...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.