Vue2 源码(一)Vue 的初始化

2021-02-21  本文已影响0人  Viewwei

Vue 的初始化

截图 11 中代表 Vue 初始化过程

init.png

声明$mount的函数文件在src/platforms/web/entry-runtime-with-compiler.js中


image.png
image.png

在申明的后面调用 mount
mount 声明在文件src/platforms/web/runtime/index.js


image.png
mount 函数最后调用 mountComponent 函数
mountComponent函数声明在文件src/core/instance/lifecycle.js
image.png

在 mountComponent 中首先声明updateComponent 函数,然后初始化一个总 watch,把updateComponent 当成参数传递过程,在 watch 组件中会执行 updateComponent.
在 updateComponent 函数中有两个重要的函数_update,_render 方法

上一篇 下一篇

猜你喜欢

热点阅读