Do you have to write this when you VUE loop: key?

I find that if I don"t write this : key , what"s the use of this? why don"t you report an error if you don"t write a loop in the cli way?
: does key have any practical effect? : what is usually followed by key ?

<div class="blog" v-for="(items, index) in all">          
</div>

Apr.21,2021

cli will be more strict with the format of vue, so the error message is prompted.
when updating the rendered element list with v-for, the local reuse policy is used by default. When the list data is modified, he will determine whether a certain value is modified according to the key value. If so, re-render this item, otherwise reuse the previous elements. To put it simply, the main purpose of key is to update virtual DOM efficiently. The
key value is the unique identity in the data, such as the sequence number of the array or the id in the data.


is necessary. Strictly speaking, it is not recommended to use array index as key, but this is often done in development


this is not necessary, but it is generally written in code: key, for example, key, = "(item, index) in list": key= "index"


use index to give Vue a hint so that it can track the identity of each node. To reuse and reorder existing elements, you need to provide a unique key attribute for each item. The official website has the answer, ide/list.html-sharp%E7%94%A8-v-for-%E6%8A%8A%E4%B8%80%E4%B8%AA%E6%95%B0%E7%BB%84%E5%AF%B9%E5%BA%94%E4%B8%BA%E4%B8%80%E7%BB%84%E5%85%83%E7%B4%A0" rel=" nofollow noreferrer "> key

Menu