qq_陈祥芬_0
2017-10-10 21:06
(function(global, factory) {
factory(global);
}(typeof window !== "undefined" ? window : this, function(window, noGlobal) {
var jQuery = function( selector, context ) {
return new jQuery.fn.init( selector, context );
(function(global, factory) { factory(global); }(typeof window !== "undefined" ? window : this, function(window, noGlobal) { var jQuery = function( selector, context ) { return new jQuery.fn.init( selector, context );等价于(function(global) { var factory=function(global, undenfined) { var jQuery = function( selector, context ) { return new jQuery.fn.init( selector, context ); } }})(typeof window !== "undefined" ? window : this); // 其实这一部分是用来判断jQ运行环境的,第一运行环境是node.js类似CommonJS和CommonJ,第二个环境是window,就是客户端,(浏览器)
里面说过:(function(global, factory) {
factory(global);
}(typeof window !== "undefined" ? window : this, function(window, noGlobal) {
var jQuery = function( selector, context ) {
return new jQuery.fn.init( selector, context );等价于
(function(global) {
var factory=function(global, undenfined) {
var jQuery = function( selector, context ) {
return new jQuery.fn.init( selector, context );
}
}
})(typeof window !== "undefined" ? window : this);
factory参数传入的是个function,就是后面括号里的function(window, noGlobal) window=global,noglobal可看作undenfined未定义
jQuery源码解析(架构与依赖模块)
84047 学习 · 280 问题
相似问题