SoFunction
Updated on 2025-04-04

vue changes the data instance after loop traversal

Don't say much nonsense, just upload the code!

<dd class="clearfix" v-for="(item,index) in tableDataList" :class="index%2 != 0 ? 'dd-bg' : ''">
  <div class="indexItem indexItem3 tal" title=""><span>{{}}{{countTotal}}</span></div>
</dd>
&lt;script type="text/ecmascript-6"&gt;
import Vue from 'vue'
import axios from 'axios'
export default {
 data(){
  return{
   tableDataList:[],//Define list data information  }
 },
 mounted(){
 //Get list data information ('url',{
  withCredentials: true
 })
  .then((res) =&gt; {
//    (res);
   let tableData = ;
    = tableData.table_list;
  })
  .catch((error) =&gt; {
   (error)
  })
 },
 computed:{
  //Convert the status number to the corresponding text explanation   countTotal() {
    for (let i = 0; i &lt; ; i++) {
     if ([i].status === 0) {
      [i].status = 'Text description 0'
     } else if ([i].status === 1) {
      [i].status = 'Text Description 1'
     } else if ([i].status === 2) {
      [i].status = 'Text Description 2'
     } else if ([i].status === 3) {
      [i].status = 'Text description 3'
     } else if ([i].status === 4) {
      [i].status = 'Text Description 4'
     } else if ([i].status === 5) {
      [i].status = 'Text description 5'
     }
     (,i,[i])
    }
   }
 }
}
&lt;/script&gt;

Notice:(,i,[i]) This code must be written, otherwise the data will not be updated

The above data example after vue changes loop traversal is all the content I share with you. I hope you can give you a reference and I hope you can support me more.