MCPcopy Index your code
hub / github.com/ygs-code/vue / lifecycleMixin

Function lifecycleMixin

vue.js:3935–4080  ·  view source on GitHub ↗
(Vue)

Source from the content-addressed store, hash-verified

3933
3934 //初始化vue 更新 销毁 函数
3935 function lifecycleMixin(Vue) {
3936 //更新数据函数
3937 Vue.prototype._update = function (vnode, hydrating) {
3938 var vm = this;
3939
3940 if (vm._isMounted) {
3941 //触发更新数据 触发生命周期函数
3942 callHook(vm, 'beforeUpdate');
3943 }
3944
3945 //获取 vue 的el节点
3946 var prevEl = vm.$el;
3947 //vue 的标准 vnode
3948 var prevVnode = vm._vnode; //标志上一个 vonde
3949 console.log(prevVnode)
3950
3951 var prevActiveInstance = activeInstance;
3952 activeInstance = vm;
3953 vm._vnode = vnode; //标志上一个 vonde
3954 // Vue.prototype.__patch__ is injected in entry points 注入入口点
3955 // based on the rendering backend used. 基于所使用的呈现后端。
3956 if (!prevVnode) { //如果这个prevVnode不存在表示上一次没有创建过vnode,这个组件或者new Vue 是第一次进来
3957 // initial render 起始指令
3958 //创建dmo 虚拟dom
3959 console.log('vm.$el=')
3960 console.log(vm.$el)
3961 console.log(['vnode=', vnode])
3962 console.log(['hydrating=', hydrating])
3963 console.log(['vm.$options._parentElm=', vm.$options._parentElm])
3964 console.log(['vm.$options._refElm=', vm.$options._refElm])
3965 console.log('====vm.$el===')
3966 console.log(vm.$el)
3967
3968 debugger;
3969 //更新虚拟dom
3970 vm.$el = vm.__patch__(
3971 vm.$el, //真正的dom
3972 vnode, //vnode
3973 hydrating, // 空
3974 false /* removeOnly */,
3975 vm.$options._parentElm, //父节点 空
3976 vm.$options._refElm //当前节点 空
3977 );
3978 console.log('=vm.$el=')
3979 console.log(vm.$el)
3980 // no need for the ref nodes after initial patch 初始补丁之后不需要ref节点
3981 // this prevents keeping a detached DOM tree in memory (#5851) 这可以防止在内存中保留分离的DOM树
3982 vm.$options._parentElm = vm.$options._refElm = null;
3983 } else { //如果这个prevVnode存在,表示vno的已经创建过,只是更新数据而已
3984 // updates 更新 上一个旧的节点prevVnode 更新虚拟dom
3985 vm.$el = vm.__patch__(prevVnode, vnode);
3986 }
3987 activeInstance = prevActiveInstance; //vue实例化的对象
3988 // update __vue__ reference 更新vue参考
3989 console.log('==prevEl==')
3990 console.log(prevEl)
3991 console.log(typeof prevEl)
3992 console.log(Object.prototype.toString.call(prevEl))

Callers 1

vue.jsFile · 0.85

Calls 2

callHookFunction · 0.85
removeFunction · 0.85

Tested by

no test coverage detected