Home > Net >  How can I add ternary check in the value of a prop?
How can I add ternary check in the value of a prop?

Time:01-21

enter image description here

I'm trying to add an if-check to my chip

If type == 1 I want make the color = Secondary, Otherwise, green.

I've tried

<v-chip small  color="'{{ item.type_id == 1 ? 'Secondary' : 'Green' }}'"> {{ item.type_id == 1 ? 'Marketing' : 'Product' }} </v-chip>

I got a crash.

CodePudding user response:

Bind it using : and remove the {{}} :

:color="`${item.type_id == 1 ? 'secondary' : 'green'}`"

CodePudding user response:

<v-chip small  :color="item.type_id == 1 ? 'Secondary' : 'Green'"> {{ item.type_id == 1 ? 'Marketing' : 'Product' }} </v-chip>
  •  Tags:  
  • Related