I'm struggling coming up with a solution to what seems to be a basic problem.
I have a template that uses a v-for loop to create some content, inside this content I need to run a function to check to see if the contentID matches an ID from a separate list. If it matches I need to take that data and show it in my loop . Currently the only way to get that data is to run the function that checks multiple times, i.e
methods: {
findClientName (clientId) {
for (let name of this.clientList) {
if (name.id == clientId) {
return {
name
}
}
}
}
<v-card-text>
{{ findClientName(item.client_id).name.f_name }}
{{ findClientName(item.client_id).name.l_name }}
</v-card-text>
That seems like a pretty ineffective way of doing it because I need to call the method on every part of the data I want, isn't there a way to just assign it to a local variable inside the template, like..
{ clientData = findClientName(item.client_id) }
{{ clientData.f_name }}
{{ clientData.l_name }}
What am I missing or not thinking of?
v-forloop?v-card-textin a new component. Then you can use a computed propery or method to get the client name and use it as many times as you need it.