I'm using MongoDB and vue.js to display a content from my db, the content is returned as an object with several properties containing other objects.
But the problem is that the v-for function of vue.js is randomly displaying the content.
In my DB, the content is sorted by field creation, and stay in this position.
When I get the object in this.statics, if I console.log it, I have those fields by alphabetic sort. But what I don't understand is : when i display it with a v-for they never come out in the same order.
here is my vue code :
h3 Static elements
.content-wrap(v-if="Object.keys(statics).length > 0")
.menu-admin
.btn(v-for="(content, key) in statics" @click="activeStatic = key") {{key}}
.content(v-for="(content, key) in statics" v-if="key === activeStatic")
h3 {{key}}
.line
.wrap(v-for="(item, keys) in content")
h4 {{keys}}
the problem is where keysis.
here is my function who returns my object:
getStatics(statics) {
Promise.all(Object.keys(statics).map((key) => {
return PartsService.fetchDataWrap({
id: statics[key]
}).then((res) => {
statics[key] = res.data.values
})
})).then(() => {
this.statics = statics
})
},
console.log for this.statics (who never change) :
{__ob__: Observer}
my static bloc: Object
image1: (...)
image2: (...)
text1: (...)
text2: (...)