[Interview] 15_Vue DOM Diff

DOM Diff purpose/core

The core of Diff comparison is node multiplexing, but node multiplexing is not a wireless recursive search, but a comparison of the same layer, which reduces some reusability, but avoids over-optimization!

Only when two old and new nodes (Vnode nodes, not DOM) are the same node, will they compare their respective child nodes!

Diff process

1. First find the same node that does not need to be moved, with minimal consumption

2. Find the same node that needs to be moved, and the consumption is the second smallest

3. If you can't find it in the end, you will create a new node and delete it.

Guess you like

Origin blog.csdn.net/dangpugui/article/details/114823731