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);