Why does the key value of vue-v-for keep repeating?

AB are two tab pages. When switching, the addlist has been turned into an empty array. The js part prints why the index value is undefined?. Solve

<div class="tit"> A</div>
      <div class="item" v-for="item in addList" :key="item.index" v-if="addList.length>0">
        <el-input v-model="item.shelves_number" disabled></el-input>
        <el-input v-model="item.shelves_layer" disabled></el-input>
        <el-input v-model="item.shelves_layer_num" disabled></el-input>
        <span>{{item.shelves_num}}</span>
        <span><button @click="delBtn_2(item.index,addList)"></button></span>
 </div>

<div class="tit"> B</div>
      <div class="item" v-for="item in addList" :key="item.index" v-if="addList.length>0">
        <el-input v-model="item.shelves_number" disabled></el-input>
        <el-input v-model="item.shelves_layer" disabled></el-input>
        <el-input v-model="item.shelves_layer_num" disabled></el-input>
        <span>{{item.shelves_num}}</span>
        <span><button @click="delBtn_2(item.index,addList)"></button></span>
 </div>

js part

delBtn_2(index,data){ 
      console.log(index);
      data.splice(index,1);
      this.setList.splice(index,1);
Mar.01,2021

your addList there is no index attribute


add your own index,v-for= (item,index) in addList

)
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b34b86-2b483.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b34b86-2b483.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?