[Vuejs]-Conditionally apply css class based on key value pair in a array, VueJS

2👍

<div v-bind:class="{ 'myClass1': sender_id === sender_id, 'myClass2': sender_id !== sender_id }" class="otherClass"></div>

https://v2.vuejs.org/v2/guide/class-and-style.html

1👍

Use ternary operation:

<span :class="todo.sender_id === sender_id ? 'delivered' : 'arrived'">{{message}}</span>

Check a sample fiddle here

👤Ritu

Leave a comment