Answer the question
In order to leave comments, you need to log in
Vue.js How to get array object property on click?
Good day, friends.
I ask for your help in resolving the issue:
Several elements are displayed on the page through v-for, how to dynamically, by clicking on one of them, get its property, say title?
html:
<div v-for="product in products">
<div>
<div> {{ product.title }} </div>
<div> {{ product.description }} </div>
<div>
<button @click="add">click</button>
</div>
</div>
</div>
data: {
products: [
{ title: 'product one', description: 'description for one product' },
{ title: 'product two', description: 'description for two product' }
],
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question