2

I'm gathering datas from a JSON file. I would like to change the cell color to green if the value is "OK" and to red if the value is "KO". I'm using a v-simple-table like that :

<td :class="OK? 'primary' : 'accent'">{{ item.pcb1 }}</td>

With my actual solution, my entire column is green.

Do someone have any idea how to to it properly ?

Thank you

1 Answer 1

4

It seems you intend to test the value of item.pcb1 in the class conditional. Right now it's always true because it tests the literal string "OK", and any string with a value is truthy.

<td :class="item.pcb1 === 'OK' ? 'primary' : 'accent'">{{ item.pcb1 }}</td>

This way tests the value of item.pcb1 instead of a literal string.

Sign up to request clarification or add additional context in comments.

1 Comment

That's working, I tought this would test the value of my line but that was only OK everytime.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.