<tr v-for="(item,index) in list">
<th>{{index+1}}</th>
<th>{{item.name}}</th>
<th>{{item.data}}</th>
<th><a @click.prevent="remove(index)">删除{{index}}</a></th>
</tr>
删除商品
splice(index,count)
参数:
index:开始位置的索引
count:要删除元素的个数
remove(index){
//splice("索引","长度")
this.list.splice(index,1)
}
//在头部添加商品
add(){
var obj={
name:this.search,
data:new Date(),
}
this.list.unshift(obj)
},