Very simple js two-way data binding framework (III): js model black technology, jsmodel
Original Intention
Before we update the model in the js domain, we need:
Model. set ('name', 'sub ');
This is too earthy...
Like angularjs, we hope:
$ Scope. name = 'sub ';
Then bong, the view will be updated! Such a black technology must be excellent.
Target implementation
This is mainly based on the methods of "hijacking" setter and getter of aveon. For more information, see the explanation of aveon simplified version.
It is difficult to read even though it is a simplified aveon.
Sort out the following ideas:
1. vm object-> vModel object, hijack set of vm attributes, get Method
2. scanTag ()-> traverse the dom tree to find keywords, go to the vModel to find the value function, and register it with the subscriber list.
It is not very clear to go to The vModel. We must figure it out in the past few days.