1. Data
- Recursively traverse the
data
configuration and responsively process each attribute - Responsive processing is to define an
dep
instance for this attribute and carry out data hijacking.getter
Perform dependency collection andsetter
distribute updates - The component
render
creationvnode
process acquires data and triggersgetter
dependency collection - Subsequent modification of the value triggers the
setter
distribution update, and finally triggers the page update
2. Props
- Format the configuration, unified format to facilitate subsequent operations
- For each
prop
verify, processed and evaluated responsive - The modified value of the parent component triggers the parent component page update, and the
update
process assigns the new value to the child component andprops
finally triggers the child component page update
The essence of props is a data, but the responsive trigger is passed from the parent component to the child component.
3. Computed
- Traverse the
computed
configuration, define one for each itemwatcher
and perform data hijacking processing getter
The function will first determine whether the current calculated attribute requires a value, and then trigger the evaluation if necessary, without returning directly- When relying on collection, the dependent collection of the calculated attribute
data
will be the firstwatcher
dependent collection of the calculated attribute, and then the dependent collection of the calculated attributewatcher
will trigger the dependent collectiondata
of the renderingwatcher
- When modifying the dependency
data
, first trigger the update of the calculated attribute, that is, reset the parameter that requires a value. Then trigger the page update, the update process will evaluate the calculated attribute again and rely on the collection
The nature of the calculated attribute is a watcher with data hijacking function. The update process only resets the parameters and evaluates only after the getter is triggered.
4. Watch
- Traverse the
watcher
configuration, parse out thehandler
callback and monitoring path of each item , and define onewatcher
- This
watcher
is evaluated once in the initialization phase , and dependency collection is performed - When the monitoring value is modified, the dispatch update is triggered, the evaluation process is executed again for dependency collection, and finally the
handler
callback is called
The Watch attribute is essentially a Watcher, which performs dependency collection and executes callbacks
5. v-model
- The
v-model
instructions are parsed in the compilation phase , and finally decomposed intoprops
attributes,input
events, andmodel
instructions - The hook that is executed after the binding is
update
created in the component process . According to the property addition, event bindingv-model
dom
dom
create
vnode
dom
- After modifying the
input
value, it will trigger theinput
event generated in the compilation stage , assign the value to theprops
attribute, and finally trigger the responsive process