Modified28 days ago. How can I repeat a loop via v-for X (e.g. The documentation shows:. but from where does vue know the source of the objects?If I render it like the doc says, I get the number of items and items, but without content.
5858 bronze badges. 2,70122 gold badges99 silver badges1010 bronze badges. 99 silver badges1010 bronze badges. You can use an index in a range and then access the array via its index:.
Note that this is 1-indexed: in the first iteration, index is 1, and in the second iteration, index is 2, and so forth. You can also check the Official Documentation for more information. 238238 bronze badges.
6,07377 gold badges3434 silver badges5858 bronze badges. 3434 silver badges5858 bronze badges.
- I have solved it with Dov Benjamin's help like that:.
- Note that in this case, n is 1-indexed, and index is 0-indexed.
- And another method, for both V1.x and 2.x of vue.js.
Using v-bind:key to Track Elements
238238 bronze badges. 2,70122 gold badges99 silver badges1010 bronze badges.
Array Change Detection
99 silver badges1010 bronze badges. Remember, result will be from 1-5. SOLUTION 2:If you want to show limited number of elements in array.
Composing with Components
22 gold badges2525 silver badges4343 bronze badges. 4343 bronze badges. You can use the native JS slice method:.