<ul class="list-group" id="v-for-object">
<li v-for="value in object" class="list-group-item">{{ value }}</li>
</ul>
data: {
object1: {
firstName: 'Bruce Lee',
userName: 'Dragoon',
email: 'bruce@lee.ru',
adress: {
country: 'China',
town: 'Gong-kong'
},
}
methods: {
plainObj(obj) {
return Object.entries(obj).reduce((acc, [ k, v ]) => {
if (v instanceof Object) {
Object.assign(acc, this.plainObj(v));
} else {
acc[k] = v;
}
return acc;
}, {});
}
}
<li v-for="value in plainObj(object)" class="list-group-item">{{ value }}</li>
Vue.component('list-obj', {
template: `
<ul class="list-group">
<li v-for="value in obj" class="list-group-item">
<list-obj v-if="value instanceof Object" :obj="value"></list-obj>
<span v-else>{{ value }}</span>
</li>
</ul>`,
props: [ 'obj' ]
});
<list-obj :obj="object"></list-obj>