-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Labels
Description
开源项目中应用原型继承的案例
jQuery
var jQuery = function(selector, context) {
return new jQuery.fn.init(selector, context)
}
jQuery.fn = jQuery.prototype = {
constructor: jQuery,
... // 各种原型方法
}
jQuery.fn.init = function(selector, context, root) { ... }
jQuery.fn.init.prototype = jQuery.fn // 校正实例的原型Vue
function Vue(options) {
this._init(options)
}
// initMixin
Vue.prototype._init = function (options) { ... }
// stateMixin
Object.defineProperty(Vue.prototype, '$data', {...})
Object.defineProperty(Vue.prototype, '$props', {...})
Vue.prototype.$set = function() {...}
Vue.prototype.$delete = function() {...}
Vue.prototype.$watch = function() {...}
// eventMixin
Vue.prototype.$on = function() {...}
Vue.prototype.$once = function() {...}
Vue.prototype.$off = function() {...}
Vue.prototype.$emit = function() {...}
// lifecycleMixin
Vue.prototype._update = function() {...}
Vue.prototype.$forceUpdate = function() {...}
Vue.prototype.$destory = function() {...}
// renderMixin
Vue.prototype.$nextTick = function() {...}
Vue.prototype._render = function() {...}