In v-for, Vuejs uses index to add class to the first item, vuejsv-
(1) In v-for, use index to add class to the first item
View the CODE piece derived from my CODE piece on CODE
<A class = "list-group-item": class = "{'activity ':! Index} "v-for =" (I, index) in announcement ">
Index comes from v-for. I indicates the elements of the traversal array, and index indicates the index.
Since index starts from 0, if you want to specify that the first item has the active class, use v-bind: class = "{'activity ':! Index }"
The first item is originally false (0), the second item is true (> 0), and then the value is reversed through logical non-operators.
Therefore, the first item has the active class, but does not follow it.
If a class exists except the first one, it can be achieved by not adding logical non-operators.
Similarly, you can use an expression like index = 2 to obtain the class from the third item.
Note,My version is Vuejs2.0, so it seems that I cannot use $ index to replace it.
In v-for, the method of using index to add class to the first item is to share all the content with you in the small series. I hope to give you a reference, we also hope that you can support the customer's home.