A simple implementation of vue.
- Use
npm ito install the dependent packages - Use
webpack-server-devto start a server used for devleoping - Open
http://localhost:8080/ index.htmlshows the simplest version of Vue, including 3 core conceptsObserverDepWatcher. Andindex2.htmlshows a relatively complete version of Vue, except the 3 core concepts mentioned above, this version includes more functions:directivescompile, and it shows how the code connect all these functions together.
-
Proxy
this.xxxtothis._data.xxx.this._datais an internal attribute. -
Proxy
this.$datatothis._data. -
Add watchers to all attributes of
data, so anyget/setaction will be catched. And build the connection withWathcerthroughDep. -
Depis like a box that may contains manyWatherinstances. -
Compile html according to
elattribute. Find �all directives in the html, and createDirectiveinstances for them. In eachdirective, it will also createwatchersaccording to the attributes used in thedirective.