I have a table for fetching data from the database. I used the "status" field for managing this table.
if the status is = 1, it means "Active" else if the status is = 2, it means "Completed" else if the status is = 0, t means "Deleted".
Then I need to show the above status word in the web page table.
I used the below to show the status number.
<tr v-for="(depAcc, index) in depAccs" :key="index">
<td>{{ index + 1 }}</td>
<td>{{ depAcc.created_at }}</td>
<td>{{ depAcc.name }}</td>
<td>{{ depAcc.status }}</td>
Please instruct me to show the status word on the table.
2
Answers
I would create a data property containing the status map, like this:
Then you can reference that in your markup:
In Vue, anything inside double braces
{{ //this }}
is evaluated as JS. You can therefore write a method to return strings based on your status, then put a function into your double braces.Then in your page script, add this method