Skip to content

Commit 549cf4c

Browse files
committed
feat: update render logic to correctly mount new elements and add example rendering
1 parent 814ec65 commit 549cf4c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

books/Vue.js设计与实现/2025-2/render/index-render-plus.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,10 @@
2828
parent.insertBefore(el, anchor);
2929
},
3030
});
31+
32+
renderer.render(
33+
{ type: 'h1', children: 'helloo' },
34+
document.querySelector('#app')
35+
);
3136
</script>
3237
</html>

books/Vue.js设计与实现/2025-2/render/render-plus.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
function patch(oldVnode, newVnode, container) {
88
// 如果 n1 不存在,意味着挂载,则调用 mountElemnet 函数完成挂载
99
if (!oldVnode) {
10-
mountElement(oldVnode, container);
10+
mountElement(newVnode, container);
1111
} else {
1212
// n1 存在,意味着打补丁
1313
}

0 commit comments

Comments
 (0)