Vue source code analysis (2) template analysis

The overall process: Take out all the child nodes of el and place them in the fragment (that is, the original position is empty, because a node has only one father), and then initialize and compile in memory (analyze the template), that is, all levels in the fragment The child node recursively compiles and analyzes, and the fragment is stuffed back.
Insert picture description here
Among them, the compilation and analysis process is divided into two steps, the brace expression text node is parsed, and the instruction attribute of the element node is parsed.
The brace expression parsing:
1 Get the matched expression string according to the regular object: there is (what is matched by the sub, get the thing inside the braces, for example, { {name}}, take the name,
2 and then from the data Take out the corresponding attribute value,
3 set the attribute value to the textContent of the text node

Guess you like

Origin blog.csdn.net/weixin_46013619/article/details/104388651