Struggling with a seemingly simple issue that may be easy for VueJS pros.
In my data, I have JSON objects with an attribute that can take values of 10, 20, 30, or 40. Depending on this value, I want to change the color of a v-btn
.
I've attempted multiple methods but keep running into errors.
Here's one attempt:
<v-btn
class="flex-column pa-6"
:class="getColor(item.type)"
>
where the getColor method is defined as follows:
getColor: function(type)
{
return this.color[type]
}
Another approach I tried was:
<v-btn
class="flex-column pa-6"
v-bind:class= "[item.type == '10' ? color['10'] : color['20'] ]"
>
This works, however, it always defaults to color['20']. Why isn't my condition working correctly?
The v-for loop in question looks like this:
<v-card
v-for="incident in incidents"
:key="incident"
class="mx-auto"
>