(vm)
| 6579 | * |
| 6580 | */ |
| 6581 | function initRender(vm) { |
| 6582 | //vm 是Vue 对象 |
| 6583 | vm._vnode = null; // the root of the child tree 上一个 vonde |
| 6584 | vm._staticTrees = null; // v-once cached trees v-once缓存的树 |
| 6585 | var options = vm.$options; //获取参数 |
| 6586 | var parentVnode = vm.$vnode = options._parentVnode; // the placeholder node in parent tree 父树中的占位符节点 |
| 6587 | var renderContext = parentVnode && parentVnode.context; // this 上下文 |
| 6588 | //判断children 有没有分发式插槽 并且过滤掉空的插槽,并且收集插槽 |
| 6589 | vm.$slots = resolveSlots(options._renderChildren, renderContext); |
| 6590 | vm.$scopedSlots = emptyObject; |
| 6591 | // bind the createElement fn to this instance |
| 6592 | // so that we get proper render context inside it. |
| 6593 | // args order: tag, data, children, normalizationType, alwaysNormalize |
| 6594 | // internal version is used by render functions compiled from templates |
| 6595 | //将createElement fn绑定到这个实例 |
| 6596 | //这样我们就得到了合适的渲染上下文。 |
| 6597 | // args order: tag, data, children, normalizationType, alwaysNormalize |
| 6598 | //内部版本由模板编译的呈现函数使用 |
| 6599 | //创建虚拟dom的数据结构 |
| 6600 | vm._c = function (a, b, c, d) { |
| 6601 | console.log(a) |
| 6602 | console.log(b) |
| 6603 | console.log(c) |
| 6604 | console.log(d) |
| 6605 | |
| 6606 | return createElement( |
| 6607 | vm, //vm new Vue 实例化的对象 |
| 6608 | a, //有可能是vonde或者指令 |
| 6609 | b, |
| 6610 | c, |
| 6611 | d, |
| 6612 | false |
| 6613 | ); |
| 6614 | }; |
| 6615 | // normalization is always applied for the public version, used in |
| 6616 | //的公共版本总是应用规范化 |
| 6617 | // user-written render functions. |
| 6618 | //用户编写的渲染功能。 |
| 6619 | vm.$createElement = function (a, b, c, d) { |
| 6620 | |
| 6621 | return createElement(vm, a, b, c, d, true); |
| 6622 | }; |
| 6623 | |
| 6624 | // $attrs & $listeners are exposed for easier HOC creation. |
| 6625 | // they need to be reactive so that HOCs using them are always updated |
| 6626 | // $attrs和$listener将被公开,以便更容易地进行临时创建。 |
| 6627 | //它们需要是反应性的,以便使用它们的HOCs总是更新的 |
| 6628 | var parentData = parentVnode && parentVnode.data; //获取父vnode |
| 6629 | |
| 6630 | /* istanbul ignore else */ |
| 6631 | { |
| 6632 | // 通过defineProperty的set方法去通知notify()订阅者subscribers有新的值修改 |
| 6633 | defineReactive( |
| 6634 | vm, |
| 6635 | '$attrs', |
| 6636 | parentData && parentData.attrs || emptyObject, |
| 6637 | function () { |
| 6638 | !isUpdatingChildComponent && warn("$attrs is readonly.", vm); |
no test coverage detected