How do I get v-for to output an array of objects in a specific order?

I have an array of objects: {2buret"Li Si", 1V "Zhang San", 3R "Wang Wu"}, and I want to output them in this order.
if you use v-for to traverse, the output will be as follows: {1 ASCII "Zhang San", 2 ASCII"Li Si", 3 ASCII "Wang Wu"}

I just want to add indexes to implement the function. {1: {2: Li Si}, 2: {1: Zhang San}, 3: {3: Wang Wu}

but this requires a lot of code changes.
is there a more elegant way to modify the rendering order of v-for?
(check the document above, but Baidu can"t find a solution)

can only customize filters? But the filter is equivalent to being sequentially bound to a specific array. Cannot be decoupled.
also hope for advice!

< hr > < H2 > update in 16 minutes < / H2 >

I thought for a moment whether I could encapsulate a filter function.
pass in a "fixed array of objects" each time, and then this function, through pop,shift or something, returns the desired result.
so you can reuse it. Although it is troublesome to write functions, it will be convenient in the future.

< hr > < H2 > [this post has been solved, and the correct solution is my answer below. ] < / H2 >

thanks to the above two friends for their advice.


I can't do this, at least I can't.

There is no order in the

object, so be sure to access the key according to ASCII when you access it.

you can consider defining it according to the array definition:

[{2:''}, {1:''}, {3:''}]

arrays are accessed sequentially.


Thank you two upstairs for your advice.
I tried it today, and the correct way to write it is as follows:

[
    {id:2,username:''}, 
    {id:1,username:''}, 
    {id:3,username:''}
]

so that you can use list. in v-for Key name output value!
vFF = "(value,key,index) in list
then fetch the value with {{value.username}}!


in the same way, it is OK to use Map.

const data = new Map([[2, ''],[1, '']])

map is saved in order

Menu