js-way binding and virtual dom

A. Suppose html elements inside the "[[]]" in single binding "{}" in the binding

II. Suppose you come out of the html element is created through a virtual dom

Js property by the idea of ​​objects set to intercept and get treatment, call the appropriate method to update the elements;

set and get to see what I wrote can intercept       js native imitate Polymer2.0 property monitor

The first case:

      1. with a statement to the variable over js obj = {}

      2. All property of obj set to get and set methods

      3.get value operation

      Out with a refresh trigger 4.set

      5. Suppose obj has a property

      6. There are elements "[[a]]" or "{{a}}" 

      7.html you do not know "[[]]" and "{}" is doing, except that a string

      8. Then you need to implement a parser to "[[]]" and "{}" inside a parsed (and the current element recorded for updating)

      9 which obj matched to "a" put "[[a]]" or "{{a}}" to replace the value of the variable a

      10. The modified obj.a = 'n'; Method set to trigger "[[a]]" or "{{a}}" is replaced n

The second case:

Dom target node analog implementations not described here
   
each element to be parsed into a target dom 

A repeat of 12345

We can be dynamically bound to the contents of his `$ {obj.a}` 

The binding dom to record to update

       

Guess you like

Origin blog.csdn.net/github_38108899/article/details/86487618