What is the function of the key in v-for?

In-place reuse strategy

When vue performs list rendering, it will follow the in-place reuse strategy by default: directly reuse the existing tags, and will not delete and create all the tags again, only re-render the data, and then create a new one Until the data rendering is complete.

key

The key attribute can be used to improve the efficiency of v-for rendering. When using v-for, vue needs to add a key attribute to each element. This key attribute is unique to avoid data confusion. Vue performs the list When rendering, it will not change the original elements and data, but create new elements and render the new data in.

Guess you like

Origin blog.csdn.net/weixin_43912756/article/details/108280475