Answer the question
In order to leave comments, you need to log in
How to get the index of a list item when clicking on a link inside it?
There is a pattern
<li v-for="(element, index) in elements" :key="index"><a href="#" @click="getElement">{{ element.param }}</a></li>
getElement(e) {
e.preventDefault()
}
Answer the question
In order to leave comments, you need to log in
<li v-for="(element, index) in elements" :key="index"><a href="#" @click="getElement(index)">{{ element.param }}</a></li>
getElement(index) {
e.preventDefault()
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question