MCPcopy Create free account
hub / github.com/ygs-code/vue / mountComponent

Function mountComponent

vue.js:4083–4189  ·  view source on GitHub ↗
(
        vm,  //vnode
        el,  //dom
        hydrating
    )

Source from the content-addressed store, hash-verified

4081
4082 //安装组件
4083 function mountComponent(
4084 vm, //vnode
4085 el, //dom
4086 hydrating
4087 ) {
4088 vm.$el = el; //dom
4089 console.log(vm.$options.render)
4090
4091 //如果参数中没有渲染
4092 if (!vm.$options.render) { //实例化vm的渲染函数,虚拟dom调用参数的渲染函数
4093 //创建一个空的组件
4094 vm.$options.render = createEmptyVNode;
4095
4096 {
4097 /* istanbul ignore if */
4098 //如果参数中的模板第一个不为# 号则会 警告
4099 if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
4100 vm.$options.el || el) {
4101 warn(
4102 'You are using the runtime-only build of Vue where the template ' +
4103 'compiler is not available. Either pre-compile the templates into ' +
4104 'render functions, or use the compiler-included build.',
4105 vm
4106 );
4107 } else {
4108 warn(
4109 'Failed to mount component: template or render function not defined.',
4110 vm
4111 );
4112 }
4113 }
4114 }
4115
4116
4117
4118 //执行生命周期函数 beforeMount
4119 callHook(vm, 'beforeMount');
4120 //更新组件
4121 var updateComponent;
4122 /* istanbul ignore if */
4123 //如果开发环境
4124 if ("development" !== 'production' && config.performance && mark) {
4125 updateComponent = function () {
4126 var name = vm._name;
4127 var id = vm._uid;
4128 var startTag = "vue-perf-start:" + id;
4129 var endTag = "vue-perf-end:" + id;
4130
4131 mark(startTag); //插入一个名称 并且记录插入名称的时间
4132 var vnode = vm._render();
4133 mark(endTag);
4134 measure(("vue " + name + " render"), startTag, endTag);
4135
4136 mark(startTag); //浏览器 性能时间戳监听
4137 //更新组件
4138 vm._update(vnode, hydrating);
4139 mark(endTag);
4140 measure(("vue " + name + " patch"), startTag, endTag);

Callers 1

vue.jsFile · 0.85

Calls 1

callHookFunction · 0.85

Tested by

no test coverage detected