嗨,我希望有人可以在这里帮助我:) 我正在尝试设置一个类似于 jQuery 的时尚库。这是我到目前为止所拥有的。
/*!
* Sentinal Javascript Library V1.0.0
* http://sentinal.com
*
* Depends on jQuery v1.9.1
*
* Copyright 2013 Sentinal Team and other contributors
* Released under license
* http://sentinal.com/license
*
* Date 25-3-2013
*/
(function ( window, location, $, undefined ){
// Can't do this because several apps including ASP.NET trace
// the stack via arguments.caller.callee and Firefox dies if
// you try to trace through "use strict" call chains. (#13335)
// Support: Firefox 18+
//"use strict";
var
// A central reference to the root Sentinal(document)
rootSentinal,
// Use the correct document accordingly with window argument (sandbox)
document = window.document,
location = window.location,
// Map over Sentinal in case of overwrite
_Sentinal = window.Sentinal,
// Map over the $S alias in case of overwrite (Namespace alias for Sentinal)
_$S = window.$S,
// Version of this library
core_version = "1.0.0",
// Define a local copy of Sentinal
Sentinal = function() {
// The Sentinal object is actually just the init constructor 'enhanced'
return new Sentinal.fn.init();
};
Sentinal.fn = Sentinal.prototype = {
// The current version of Sentinal being used
Sentinal: core_version,
constructor: Sentinal,
init: function (){
$(document).ready(function(){
$('body').append('<h1>It Works!</h1>');
console.log( "Sentinal Version is reporting : " + $S.fn.version() );
});
},
version: function (){
return core_version;
},
render: function (){
},
send: function () {
},
recieve: function () {
}
};
// Give the init function the jQuery prototype for later instantiation
Sentinal.fn.init.prototype = Sentinal.fn;
window.Sentinal = window.$S = Sentinal;
})( window, location, jQuery );
我现在遇到的问题要么与我的图书馆不知道 $(document).ready 有关。或者是范围问题,但是其中包含一些 jQuery 的 init 方法不会将 html 附加到文档的正文中,并且 console.log 也不起作用。
任何信息都将受到极大的欢迎:)