要實現一個庫,我必須將JQuery升級到它的3.1.1版本。Jquery更新到3.1.1 - >匿名函數
它了相當不錯,儘管很容易固定,一些研究,
但一個我使用我的網站上的小腳本不工作了,我的JS知識幾個廢棄的函數都不甚理想。
有問題的腳本是國別(它顯示國家名稱/標誌的輸入列表中),這裏有我在我的控制檯獲取錯誤:
r.fn.load @ jQuery的3.1.1。 min.js:4
(匿名功能)@ countrySelect.js:32
(匿名功能)@ countrySelect.js:8
(匿名功能)@ countrySelect.js:10
,這裏是腳本的第34行:
// wrap in UMD - see https://github.com/umdjs/umd/blob/master/jqueryPlugin.js
(function(factory) {
if (typeof define === "function" && define.amd) {
define([ "jquery" ], function($) {
factory($, window, document);
});
} else {
factory(jQuery, window, document); // <------ LINE 8
}
})(function($, window, document, undefined) { // <------ LINE 10
"use strict";
var pluginName = "countrySelect", id = 1, // give each instance its own ID for namespaced event handling
defaults = {
// Default country
defaultCountry: "",
// Position the selected flag inside or outside of the input
defaultStyling: "inside",
// Display only these countries
onlyCountries: [],
// The countries at the top of the list. Defaults to United States and United Kingdom
preferredCountries: [ "fr", "us", "gb", "ru", "cn" ]
}, keys = {
UP: 38,
DOWN: 40,
ENTER: 13,
ESC: 27,
PLUS: 43,
A: 65,
Z: 90
}, windowLoaded = false;
// keep track of if the window.load event has fired as impossible to check after the fact
$(window).load(function() { // <------ LINE 32
windowLoaded = true;
});
我真的很感激一些幫助理解爲什麼它不工作了,我不能弄明白爲止。我應該如何解決這個問題?
什麼是實際的錯誤? JavaScript通常輸出錯誤是什麼,不僅僅是「在哪裏」,它是 –