The basic principle of vue2.0 in MVVM
Construction ...
Implementation of two-way binding
angular used is dirty check the value of that difference contrast old and new values in the various events triggered.
vue is used in data hijacking , in conjunction with the publisher - subscriber mode, Object.defineProperty()
to hijack each attribute getter
/ setter
publish messages to subscribers when the data changes, the trigger monitor callback.
- Initialization, all data (the Data) , layer by layer recursively traverse a number of the same name became the setter / getter , then these properties made into its one to one listener (Watcher) , and stored in a subscription (Dep) object an array.
- By a compiler (the Compile) where the DOM tag data to be displayed, replacing the data (Data) the current value becomes html rendering a band data.
- Once the value change triggers a observers (Observer) object that to perform subscription (Dep) , stored in the plurality of object listener (Watcher) array, a watcher found to operate in line with the change value corresponding update method, by executing the compiler (compile) Furnished callback function in advance, rendering DOM again