I would like to avoid image
value in below code.image
is a key for property
. How can I do that ?
<tbody>
<tr v-for="obj in data" :id="obj.id">
<td v-for="property in obj">{{property}}</td>
</tr>
</tbody>
I would like to avoid image
value in below code.image
is a key for property
. How can I do that ?
<tbody>
<tr v-for="obj in data" :id="obj.id">
<td v-for="property in obj">{{property}}</td>
</tr>
</tbody>
Let check it out: v-for
with an Object, v-for
with v-if
.
<td v-for="(value, property) in obj" v-if="property!='image'">
{{value}}
</td>
<td v-for="property in obj" v-if="!property.image">{{property}}</td>
. But it is not working. Thanks –
Zechariah <td v-for="(value, property) in obj" v-if="property!='image'">{{value}}</td>
–
Pelite The Accepted answer is an anti-pattern because you should not mix v-for
and v-if
on the same node in VueJs 2+ as Thomas van Broekhoven pointed out. Instead, you can just chain a filter onto the object. Here is an example using an ES6 arrow function which should* work.
<tbody>
<tr v-for="obj in data" :id="obj.id">
<td v-for="property in obj.filter(property => property !== 'image')">{{property}}</td>
</tr>
</tbody>
'v-for' directives require that attribute value.
–
Ralaigh Let check it out: v-for
with an Object, v-for
with v-if
.
<td v-for="(value, property) in obj" v-if="property!='image'">
{{value}}
</td>
<td v-for="property in obj" v-if="!property.image">{{property}}</td>
. But it is not working. Thanks –
Zechariah <td v-for="(value, property) in obj" v-if="property!='image'">{{value}}</td>
–
Pelite © 2022 - 2024 — McMap. All rights reserved.
td
for any object that has an image? – Kerakerala{{property}}
. But I would not like to print value ofimage
property. – Zechariahproperty
an object? Because the way you're callingproperty.image
suggests that it is. – Kerakeralaproperty
is a value. I am updating my question. I don't know how to do that's why I was callingproperty.image
. Thanks – Zechariah