代码拉取完成,页面将自动刷新
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="app"></div>
<div style="font-size: 14px; position:absolute;bottom:20px; left:10px;">
源代码地址:https://gitee.com/xiao_yan_bin/vue_code<br/>
github: https://github.com/xiaoyanbin/vue_code<br/>
vue设计与实现,持续更新,建议点赞收藏,有问题可以在评论区留言
</div>
</body>
<script>
function mountComponent(vnode, container,anchor) {
const componentOptions = vnode.type
const {render , data,beforeCreate, created, beforeMount, mounted,beforeUpdate,updated, } = componentOptions
beforeCreate && beforeCreate()
const state = reactive(data())
// 定义组件实例,
const instance = {
state,
isMounted: false,
subTree: null,
}
created && created.call(state)
// 将组件实例挂载到vnode上
vnode.component = instance
// 将组件的render函数调用包装到effect 内
effect(()=>{
const subTree = render.call(state, state)
if(!instance.isMounted){
beforeMount && beforeMount.call(state)
// 第一次挂载 传入null
patch(null,subTree, container, anchor)
// 更新是不会到这里
instance.isMounted = true
mounted && mounted.call(state)
}else{
// 挂载
beforeUpdate && beforeUpdate.call(state)
// instance.subTree 是上一次的subTree subTree是新的subTree container是容器 anchor是锚点
patch(instance.subTree,subTree, container, anchor)
updated && updated.call(state)
}
// 更新instance.subTree
instance.subTree = subTree
},{scheduler:queueJob})
}
</script>
</html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。