VUE source code analysis -1- initial article: Vue definition path search

From here, record the VUE source code analysis.

1. Pull the vue source code locally for easy analysis

The vue source code address comes from the world's largest same-sex exchange website - gitHub: https://github.com/vuejs/vue

We clone the dev branch code to the local

cd to the local storage directory:

cd 你的本地存放目录

git clone clone the code 

git clone https://github.com/vuejs/vue.git 

⚠️ If you want to view directly on github, you can install a plug-in Octotree, which can generate a side navigation on the left side of github for easy viewing

2. After cloning the source code, officially start

First of all, when vue is running, we usually run npm run dev. How does vue run? Let's start with npm run dev.

Open 1.package.json and find the scripts -> dev setting:

As you can see, this is rollup started "web-full-dev" in "scripts/config.js". Let's open this file 2.vue/scripts/config.js and find web-full-dev

As we can see above, the entry entry is the "web/entry-runtime-with-compiler.js" file, we find 3. src/platforms/web/entry-runtime-with-compiler.js

It is found that Vue is imported, and then find 4. src/platforms/web//runtime/index 

Find that vue is still imported, and then find 5. src/core/index

Harm, or introduce, and then find 6. src/core/instance/index 

Wow, I finally found the place where Vue was born. It is a function.

 

Summary: Vue's definition address: src/core/instance/index.js

Guess you like

Origin blog.csdn.net/RedaTao/article/details/109640055