File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -538,6 +538,8 @@ export function createRenderer(options) {
538
538
// 如果有 next 的话, 说明需要更新组件的数据(props,slots 等)
539
539
// 先更新组件的数据,然后更新完成后,在继续对比当前组件的子元素
540
540
if ( next ) {
541
+ // 问题是 next 和 vnode 的区别是什么
542
+ debugger ;
541
543
next . el = vnode . el ;
542
544
updateComponentPreRender ( instance , next ) ;
543
545
}
@@ -577,11 +579,22 @@ export function createRenderer(options) {
577
579
}
578
580
579
581
function updateComponentPreRender ( instance , nextVNode ) {
582
+ // 更新 nextVNode 的组件实例
583
+ // 现在 instance.vnode 是组件实例更新前的
584
+ // 所以之前的 props 就是基于 instance.vnode.props 来获取
585
+ // 接着需要更新 vnode ,方便下一次更新的时候获取到正确的值
586
+ nextVNode . component = instance ;
587
+ // TODO 后面更新 props 的时候需要对比
588
+ // const prevProps = instance.vnode.props;
589
+ instance . vnode = nextVNode ;
590
+ instance . next = null ;
591
+
580
592
const { props } = nextVNode ;
581
593
console . log ( "更新组件的 props" , props ) ;
582
594
instance . props = props ;
583
595
console . log ( "更新组件的 slots" ) ;
584
596
// TODO 更新组件的 slots
597
+ // 需要重置 vnode
585
598
}
586
599
587
600
return {
You can’t perform that action at this time.
0 commit comments