# 构造函数

构造函数Vue的构造过程,这里以runtime+compiler版本为例。依赖路径为src\platforms\web\entry-runtime-with-compiler.ts -> src\platforms\web\runtime\index.ts -> src\core\index.ts -> src\core\instance\index.ts

import("../vue.study.esm.js").then((module) => {
    const { Vue } = module; 
})

如下图src\core\instance\index.ts中设置断点,观察Vue对象变化可以发现其中主要是在Vue.prototype上添加各类方法。 src\core\instance\index.ts

src\core\index.ts中,主要在Vue对象上添加了各类方法,同时也在Vue.prototype上添加部分属性。 src\core\index.ts

src\platforms\web\runtime\index.ts中,主要设置Vue.configVue.options,同时在Vue.prototype上添加__patch__$mount方法。 src\platforms\web\runtime\index.ts

src\platforms\web\entry-runtime-with-compiler.ts中重置了Vue.prototype上的$mount方法,同时向Vue对象上添加compile方法。 src\platforms\web\entry-runtime-with-compiler.ts