<table>
<tr v-for="(items, index) in items" :key="index">
<td>
<input label="名称" placeholder="输入名称" />
</td>
<td>
<input label="规格" placeholder="输入规格" />
</td>
<td>
<input label="数量" placeholder="输入数量" />
</td>
<td>
<input label="价格" placeholder="输入价格" />
</td>
<td>
<button v-if="index == this.items.length-1" @click="addRow">
增加
</button>
<button v-else @click="delRow(index)">
删除
</button>
</td>
</tr>
</table>
<script>
export default {
data() {
return {
items: [
{},
{},
]
}
},
created() { },
methods: {
addRow() {
this.items.push({})
},
delRow(index) {
this.items.splice(index, 1)
}
}
};
</script>
