Vue in v-for why should we increase key

Example: We want to add a F between B and C
Here Insert Picture Description

The default is to implement the algorithm Diff such
Here Insert Picture Description
that is updated as C F, D is updated to C, E is updated to D, and finally insert E

So we need to make a key that uniquely identifies each node, Diff algorithm can correctly identify this node, finding the right location area to insert a new node.
Here Insert Picture Description

Published 34 original articles · won praise 23 · views 7572

Guess you like

Origin blog.csdn.net/qq_37330613/article/details/104812362