【发布时间】:2020-11-10 10:21:23
【问题描述】:
这是我的代码示例。 第一行“end_no = 10” 我需要从“end_no”添加+1到第二行“start_no”。第二行“start_no”应该是11,然后从每行start_no自动添加+1。 如何设置代码?请帮帮我。
export default{
data(){
return{
form:{
items:[]
},
}
},
methods:{
addNewLine(){
this.form.items.push({
start_no:1,
end_no:10,
})
},
}
}
<div>
<button @click="addNewLine">Add New Line</button>
</div>
<form>
<table>
<thead>
<tr>
<th>SL.</th>
<th>Name</th>
<th>Start No</th>
<th>End No</th>
</tr>
</thead>
<tbody>
<tr v-for="(item , index) in form.items">
<td>{{index + 1}}</td>
<td><input type="text" v-model="item.start_no" /></td>
<td><input type="text" v-model="item.end_no" /></td>
</tr>
</tbody>
</table>
</form>
【问题讨论】: