Getting undefined while access index parameter while iterating over objects in vue.js

Viewed 1682

Please refer below code. Here I am using v-for to iterate over the object.

In this I am trying to access index parameter but I am getting it blank.

<a href="#" class="list-group-item" v-for="(event, key, index) in events">
    index is {{index}}
</a>

I also tried below way but got the same result:

<a href="#" class="list-group-item" v-for="event in events">
    index is {{$index}}
</a>

This is my object:

var events = [{
            name: 'event1',
            description: 'description 1',
        },
        {
            name: 'event2',
            description: 'description 2',
        }
    ];

Can anybody please help me out with this. How can I access index property here.

Thanks in advance.

2 Answers
Related