jquery 框架簡單分析

2021-07-16 10:19:57 字數 783 閱讀 4712

// jquery外部用乙個匿名函式自執行 然後傳入引數 

(function(w,undefined))(window) //jquery 在外面用了乙個匿名函式自執行 包裹  把變數 方法 函式 包裹在裡面  然後在對外提供介面

//undefined既不是關鍵字 也不是保留字 所以要把undefined傳入進來 防止被惡意修改

var undefined = 10;

console.log(undefined);  //在低版本的瀏覽器 會列印出10 ,高版本會列印出undefined

//平時我們一般的寫法

function aaa(){}

aaa.prototype.init = function()

aaa.prototype.css = function()

var a1 = new aaa();

al.init();

//jquery 寫法

function jquery()

jquery.prototype.init = function()

jquery.prototype.css = function()

jquery.fn.init.prototype = jquery.fn; //可以寫成jquery.prototype.init.prototype = jquery.prototype;  意思就是把jquery下面的原型 賦值給了 jquery原型下的init方法下的原型

//所以就可以形成在jquery 中 呼叫就$('.').css()或者jquery('.').css()

簡單模擬JQuery框架

1.首先模擬乙個jquery物件,在這裡起名叫xjs,如下 var xjs function selector alert xjs d1 innerhtml 但是現在通過xjs返回的是乙個dom物件,這跟jquery返回的是乙個jquery物件不同。為了讓xjs返回本身自己,需要擴充套件xjs。va...

ecshop 框架 簡單分析

include init.php.主函式檔案 includes inc constant.php 常量,暫時沒多大用 includes cls ecshop.php 基礎類 includes cls error.php 使用者級錯誤處理類 includes lib time.php 時間函式 inc...

jquery原理的簡單分析

jquery的外衣 jquery是乙個輕量級的js框架,這點相信大部分人都聽過,而jquery之所以有這樣乙個稱呼,就是因為它悄悄披了一件外衣,將自己給隱藏了起來。以下擷取自jquery原始碼片段 function window,undefined window 上面這一小段 來自於1.9.0當中j...