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>
Join Stack Overflow to learn, share knowledge, and build your career.
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
– abu abu
Dec 18 '17 at 4:37
<td v-for="(value, property) in obj" v-if="property!='image'">{{value}}</td>
– Ben
Dec 18 '17 at 4:59
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>
td
for any object that has an image? – Matt Dec 18 '17 at 2:53{{property}}
. But I would not like to print value ofimage
property. – abu abu Dec 18 '17 at 4:06property
an object? Because the way you're callingproperty.image
suggests that it is. – Matt Dec 18 '17 at 4:17property
is a value. I am updating my question. I don't know how to do that's why I was callingproperty.image
. Thanks – abu abu Dec 18 '17 at 4:18