2๐
โ
As commenters have noted, order of keys in an object is not guaranteed, so your best option is to have your server emit messages in an ordered structure (like an array).
If that is not possible, I have found that key order is generally preserved in an object created all at once (like your JSON data). Object.keys(data)
, will give you an array of keys that is likely in the original order.
So instead of something like
<div v-for="value in data">
do
<div v-for="key in Object.keys(data)">
and then use data[key]
to get the value.
You can also try Object.entries
depending on whether you need IE support.
If this is going to be widely deployed, expect it to break for somebody sometime. If you just need something that works for you, this could do it.
๐คRoy J
Source:stackexchange.com