I am cycling through a Firestore collection Colours, and want to use a conditional dynamic class based on the length of array attribute alpha.
I tried:
<v-card v-for="Colour in Colours" :key="Colour.id">
<v-text-field v-model="Colour.alpha" :value="Colour.alpha" :class="Colour.alpha.length >= '1' ? 'greenClass' : 'blueClass'"></v-text-field>
Which didn't work, and have been searching for an answer, the only relevant suggestion I could find as this:
v-bind:class="{ 'greenClass': Colour.alpha.length >= 1 }"
which also did not work.
Is it possible to use .length like this?
Also, I would like to have multiple conditional classes, eg.
Colour.alpha.length == 0 -> assign class 'white'
Colour.alpha.length == 1 -> assign class 'blue'
Colour.alpha.length == 2 -> assign class 'green'
Colour.alpha.length >= 3 -> assign class 'red'
But I have a feeling this is even less likely to be possible (at least I have no idea how to implement that)
Any suggestions will be greatly appreciated.