constructor: ajQuery 這個的作用是什么?代碼如下:
ajQuery.fn = ajQuery.prototype = {
? ? name: 'aaron',
init: function(selector) {
this.selector = selector;
return this;
},
constructor: ajQuery
}
ajQuery.fn = ajQuery.prototype = {
? ? name: 'aaron',
init: function(selector) {
this.selector = selector;
return this;
},
constructor: ajQuery
}
2016-12-13
舉報
2017-10-22
因為ajQuery.fn = ajQuery.prototype = {},這相當于又構造一個新的對象“{}”,因此它本身的constructor指向的是Object,而不是ajQUERY,所以這邊需要強制指向
2016-12-25
指明?ajQuery.fn 函數的構造器是ajQuery,實例化后可以繼承ajQuery的方法。