1.添加按钮用来控制行的增加
<el-button
type="primary"
size="mini"
style= "margin-bottom: 10px"
@click="addDataBase"
>添加</el-button
>
2.与之对应的方法
addDataBase() {
this.inputForm.databaseInfoList.push({
startip:'',
endip:''
});
},
delDataBase(scope) {
this.inputForm.databaseInfoList.splice(scope.$index, 1);
},
3.对应的数据源
data () {
return {
inputForm: {
databaseInfoList:[{
startip:'',
endip:''
}],
}
}
}
4.对应的表格
<el-table
:data="inputForm.databaseInfoList"
v-loading="loading"
:class="method === 'view' ? 'readonly' : ''"
:disabled="method != 'add'"
style="margin: 0 auto; width: 100%"
:highlight-current-row="true"
>
<el-table-column
prop=""
label=""
width="110"
align="center"
type="index"
:index="indexMethod"
>
</el-table-column>
<el-table-column prop="startip" label="起始IP地址" width="400" align="center">
<template slot-scope="scope" >
<el-input
v-model="scope.row.startip"
placeholder="请填写起始IP地址"
clearable
></el-input>
</template>
</el-table-column>
<el-table-column prop="endip" label="结束IP地址" width="400" align="center" >
<template slot-scope="scope">
<div style="display: flex" >
<el-input
v-model="scope.row.endip"
placeholder="请填写结束IP地址"
clearable
></el-input>
<el-button
type="text"
@click="delDataBase(scope)"
style="margin-left: 10px"
>删除</el-button
>
</div>
</template>
</el-table-column>
</el-table>
5.效果图