function initRender (vm) {
vm._vnode = null; // 子树的根
vm._staticTrees = null; // v-once缓存的树
var options = vm.$options;
var parentVnode = vm.$vnode = options._parentVnode; // 父树中的占位符节点
var renderContext = parentVnode && parentVnode.context;
vm.$slots = resolveSlots(options._renderChildren, renderContext);
vm.$scopedSlots = emptyObject;
// 将createElement fn绑定到此实例,以便我们在其中获得适当的渲染上下文。
vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); };
// 规范化始终应用于公共版本,在用户编写的渲染函数中使用。
vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); };
// 暴露了$ attrs和$ listeners以便更容易创建HOC。
// 他们需要被动反应,以便使用它们的HOC始终更新
var parentData = parentVnode && parentVnode.data;
/* istanbul ignore else */
if (process.env.NODE_ENV !== 'production') {
defineReactive(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
!isUpdatingChildComponent && warn("$attrs is readonly.", vm);
}, true);
defineReactive(vm, '$listeners', options._parentListeners || emptyObject, function () {
!isUpdatingChildComponent && warn("$listeners is readonly.", vm);
}, true);
} else {
defineReactive(vm, '$attrs', parentData && parentData.attrs || emptyObject, null, true);
defineReactive(vm, '$listeners', options._parentListeners || emptyObject, null, true);
}
}