如下 this.componentInstance 这个this 指向谁? 为什么?
var prototypeAccessors = { child: { configurable: true } };
// DEPRECATED: alias for componentInstance for backwards compat.
/* istanbul ignore next */
prototypeAccessors.child.get = function () {
return this.componentInstance //这个this 是指向谁? 为什么?
};
Object.defineProperties( VNode.prototype, prototypeAccessors );
js 函数中的 this 指向是由调用方式决定的。
这段代码等价于:
那个函数最终其实是 VNode.prototype.child 的 getter,那么推测被调用的方式肯定是通过 Vnode 实例访问 child 属性: