How to sort vue multi-components?

problem description

I have a lot of components to reference, and the structures of these components are inconsistent, but I need to add a move up and down on top of them.
and there may be more than one component, so you need to use v-for. Render the updated view by changing the data, but because the local components are already written there in the template, even if the data changes, the location of the view will not be updated.

related codes

template:

<Initial v-for="(item,key) in currency" :key="item.id" v-if="item =="initial"" :index="key"></Initial>
<Basic v-for="(item,key) in currency" :key="item.id" v-if="item =="basic"" :index="key" @orderTake="orderTake" @deleteTake="deleteTake"></Basic>
<Introduce v-for="(item,key) in currency" :key="item.id" v-if="item =="introduce"" :index="key" @orderTake="orderTake" @deleteTake="deleteTake"></Introduce>
<Education v-for="(item,key) in currency" :key="item.id" v-if="item =="education"" :index="key" @orderTake="orderTake" @deleteTake="deleteTake"></Education>
<Work v-for="(item,key) in currency" :key="item.id" v-if="item =="work"" :index="key" @orderTake="orderTake" @deleteTake="deleteTake"></Work>
<Skill v-for="(item,key) in currency" :key="item.id" v-if="item =="skill"" :index="key" @orderTake="orderTake" @deleteTake="deleteTake"></Skill>

processing:

data() {
    return {
        currency : ["initial","basic","introduce","education","work","skill"]
      }
    },
methods:{
    orderTake(order,index){
      if(order == "asc"){
        if(index > 1){
          let str1 = this.currency[index], str2 = this.currency[index-1];
          this.currency[index] = str2;
          this.currency[index-1] = str1;
          console.log(this.currency)
        }
      }else if(order == "desc"){
        if(index < this.currency.length-1){
          let str1 = this.currency[index], str2 = this.currency[index+1];
          this.currency[index] = str2;
          this.currency[index+1] = str1;
          console.log(this.currency)
        }
      }
    }

what result do you expect? What is the error message actually seen?

Let these components sort according to my data data, rather than the location where the template is written.

do you have a boss to answer, which has been bothering you for a long time

Dec.21,2021

you can't change places if you write a template. You may have to write render if you want to solve this problem by code.
however, there is a relatively simple way to control the display position of components through css. You can learn that the CSS order attribute specifies the order of scalable items in the elastic container during layout


.

< component v deleteTake = "(item,key) in currency": is= "item": key= "item.id": index= "key" @ orderTake= "orderTake" @ deleteTake= "deleteTake" > < / component >

changed to solve the problem of is rendering template, but you need to pay attention to the problem of updating the view of the array. I didn't care before. If you just pass
array [0] = 1; this does not update the view, you need to use $set

Menu