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