I have an object in Vuejs (see below). I want to select the email value ie: "[email protected]".
{
"fields": [
{
"label": "email",
"value": "[email protected]",
},
{
"label": "firstName",
"value": "Foo",
},
{
"label": "lastName",
"value": "Bar",
},
]
}
I can do a
v-for(field in fields)
Then add an if statement to show only the email
<div v-if="field.label == 'email'">{{field.value}}</div>
But I was wondering if there was a better way to select the field based on a key's value without having to loop through the entire data object.
I tried unsuccessfully doing things like this:
fields(label, 'email')
// and
v-if fields.label == 'email'