splice刪除數組最后一項時報錯<div class="content" :index='index'>
<p>確定要刪除品牌:{{tableList[index].name}} 嗎</p>
<button @click="del(index)">確定</button>
<button @click='cancel'>取消</button> </div>報錯代碼:del:function(id){ this.tableList.splice(id,1) for(i=0;i<this.tableList.length;i++){ this.tableList[i].id = i+1
} this.show=false}報錯數組: tableList:[
{id:1,name:'三只松鼠',timer:new Date()},
{id:2,name:'英菲尼迪',timer:new Date()},
{id:3,name:'杰克瓊斯',timer:new Date()},
{id:4,name:'雷蛇',timer:new Date()},
{id:5,name:'積家',timer:new Date()},
{id:6,name:'英偉達',timer:new Date()},
{id:7,name:'菲亞特',timer:new Date()}
]
去掉content中p標簽的name則正常運行
添加回答
舉報
0/150
提交
取消