我從 Api 獲取一些資料,我想檢查 vtype 是否為“汽車”。這是我回圈的方式:
<tr v-for="vehicles_group in vehicles_groups.data" :key="vehicles_group.gid">
<td>
<input type="checkbox">
</td>
<!-- <td>{{ vehicles_groups.gid }} </td> -->
<td>{{ vehicles_group.title }}</td>
<td>{{ vehicles_group.vtype }}</td>
<td>{{ vehicles_group.company }}</td>
<td>{{ vehicles_group.active }}</td>
<td>{{ vehicles_group.priceincludes }}</td>
<td>{{ vehicles_group.categories }}</td>
<td>{{ vehicles_group.earlybook }}</td>
<td>{{ vehicles_group.earlybook }}</td>
</tr>
vue 有沒有辦法檢查 Api 輸出的值是否是汽車控制臺的東西?
例如
if {{ vehicles_group.vtype }} == car{
console.log('its a car', vehicles_group.vtype )
}
uj5u.com熱心網友回復:
當然。
如果要v-if在模板中使用:
<td v-if="vehicles_group.vtype == 'car'">
It's a car
</td>
<td v-else>
It's not a car
</td>
如果你想在你的組件 JavaScript 代碼中這樣做,你可以像往常一樣這樣做:
if (vehicles_group.vtype == "car") {
console.log('its a car', vehicles_group.vtype )
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/388473.html
上一篇:Vuejs的性能指標
