请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

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

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吗,复制也不能?)

正在回答 回答被采纳积分+3

1回答

提问者 王王王博 2019-08-23 04:17:07

是为了避免被vm实例访问吗?

0 回复 有任何疑惑可以回复我~
  • extend 的目的就是返回一个构造器,和实例无关,没必要挂载到原型上吧
    回复 有任何疑惑可以回复我~ 2019-08-23 10:03:36
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号