Answer the question
In order to leave comments, you need to log in
How to get attribute values in vue.js?
<ul>
<li v-for="post in posts | orderBy 'date' -1"
v-on:click="showId"
:key="post.id"> // <!-- вот этого элемента -->
<p>{{ post.date }}</p>
<h3>{{ post.title }}</h3>
<p>{{ post.description }}</p>
</li>
</ul>
...
methods: {
showId: function (event) {
console.log("Получить атрибут key элемента, по которому кликнули") // <-- вот сюда
}
}
...
Answer the question
In order to leave comments, you need to log in
v-on:click="showId(post.id)"
...
showId: function (key){
console.log(key) // <-- вот сюда
}
v-on:click="showId(post)"
...
showId: function (post){
console.log(post.id) // <-- вот сюда
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question