extend方法中子类的extend属性已经指向了父类的extend,那为什么extend要作为一个静态方法,而不直接挂在Vue.prototype上呢?
来源:3-2 createComponent

王王王博
2019-08-23
const Sub = function VueComponent (options) {
this._init(options)
}
Sub.prototype = Object.create(Super.prototype)
Sub.prototype.constructor = Sub
Sub.cid = cid++
Sub.options = mergeOptions(
Super.options,
extendOptions
)
Sub['super'] = Super
// For props and computed properties, we define the proxy getters on
// the Vue instances at extension time, on the extended prototype. This
// avoids Object.defineProperty calls for each instance created.
if (Sub.options.props) {
initProps(Sub)
}
if (Sub.options.computed) {
initComputed(Sub)
}
// allow further extension/mixin/plugin usage
Sub.extend = Super.extend
Sub.mixin = Super.mixin
Sub.use = Super.use
(发现看视频的页面提问的输入框只能往左后退一步<-,不能->前进,bug吗,复制也不能?)
写回答
1回答
-
王王王博
提问者
2019-08-23
是为了避免被vm实例访问吗?
012019-08-23
相似问题