vue element表格 实现添加按钮,表格后新增一行的样式

稍微理了一下思路:
在这里插入图片描述
效果图:
在这里插入图片描述
实现:

<el-button @click="addziduan">添加字段</el-button>
<el-table :data="prototypes" class="kong-box">
    <el-table-column type="index" label="序号" width="100" align="center"></el-table-column>
    <el-table-column prop="aaa" label="姓名" width="480" align="center">
        <template slot-scope="scope">
            <span v-if="scope.row.vVisible">{{scope.row.fieldDescription}}</span>
            <el-input v-else  ref="marker1"v-model="scope.row.fieldDescription" class="inputheight"></el-input>
        </template>
    </el-table-column>
    <el-table-column label="操作" width="160" align="center">
        <template slot-scope="scope">
            <span v-if="scope.row.vVisible" class="items" @click="edit(scope.row)">编辑</span>
            <span v-else class="items" @click="save(scope.row)">保存</span>
            <span>|</span>
            <span class="items" @click="deleteit(scope.row)">删除</span>
        </template>
    </el-table-column>
</el-table>

表格原本绑定的数据

prototypes:[
	{
	   	name: 'type',
	    describe: '设备类型字段,不可修改',
	    isNull: false,
	    vVisible: true
	}
	]
// 添加字段按钮
addziduan() {
   // 向表格数组中数据添加一行
   this.prototypes.push({
       index: this.prototypes.length,
       name: '',
       describe: '',
       isNull: false,
       vVisible: false
   })
   console.log(this.prototypes)
},
// 删除按钮
deleteit(row) {
    this.prototypes.splice(row.index, 1)
},
  • 4
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值