I want to ask how can I doing if/else condition in this tag?
<td data-label="Status">{{$t('Status'+item.cStatus)}}</td>
What I want is
if(item.cStatus == NW){
color:red
}
else{
color:blue
}
I want to ask how can I doing if/else condition in this tag?
<td data-label="Status">{{$t('Status'+item.cStatus)}}</td>
What I want is
if(item.cStatus == NW){
color:red
}
else{
color:blue
}
You can pass an object to :class (short for v-bind:class) to dynamically toggle classes:
<td :class="[item.cStatus == NW ? 'red' : 'blue']" data-label="Status">{{$t('Status'+item.cStatus)}}</td>
The above syntax means the presence of the red class will be determined by the truthiness of the data property item.cStatus == NW.
Then you can add your desired style to red or blue class
You can also do it by :style object
You can find more details here
Try with below code
<th:block th:if="${item.cStatus == 'NW'}">
<td data-label="Status" style="color:red;">{{$t('Status'+item.cStatus)}}</td>
</th:block>
<th:block th:unless="${item.cStatus == 'NW'}">
<td data-label="Status" style="color:blue;">{{$t('Status'+item.cStatus)}}</td>
</th:block>