I am trying to figure out something and having issues with it. I have some icons data that I am receiving from an array inside an array and I want to put an event handler on only one of the icons. For example, let's say put an event handler on thumbs up icon to hide a paragraph (something like that).
I have made a codepen for demonstration: https://codepen.io/anon/pen/gNxdER
<div id="app">
<v-app id="inspire">
<v-container>
<v-data-table
v-model="selected"
:headers="headers"
:items="desserts"
item-key="name"
>
<template v-slot:items="props">
<td>{{ props.item.name }}</td>
<td>{{ props.item.calories }}</td>
<td>{{ props.item.iron }}</td>
<td><v-icon v-for="icon in props.item.icons">{{icon}}</v-icon></td>
</template>
</v-data-table>
</v-container>
</v-app>
</div>
new Vue({
el: '#app',
data () {
return {
headers: [
{
text: 'Dessert (100g serving)',
align: 'left',
sortable: false,
value: 'name'
},
{ text: 'Calories', value: 'calories' },
{ text: 'Iron (%)', value: 'iron' },
{ text: 'Icons', value: 'icon'}
],
desserts: [
{
name: 'Frozen Yogurt',
calories: 159,
iron: '1%',
icons: [
'search',
'dashboard',
'timeline',
'thumb_up'
]
},
{
name: 'Ice cream sandwich',
calories: 237,
iron: '1%',
icons: [
'search',
'dashboard',
'timeline',
'thumb_up'
]
},
{
name: 'Eclair',
calories: 262,
iron: '7%',
icons: [
'search',
'dashboard',
'timeline',
'thumb_up'
]
},
{
name: 'Cupcake',
calories: 305,
iron: '8%',
icons: [
'search',
'dashboard',
'timeline',
'thumb_up'
]
}
]
}
}
})
Thank you for the help.