当前位置:首页 > 程序心得 > 正文内容

element table 表格添加行,删除行记录

admin5年前 (2020-05-14)程序心得1398
  <el-table
                :data="tableData"
                style="width: 100%"
                border>
            <el-table-column
                    prop="bookname"
                    :label="recoveryOne"
                    width="140px">
                <template slot-scope="scope">
                    <el-input v-model="scope.row.bookname" type="number"></el-input>
                </template>
            </el-table-column>

            <el-table-column
                    prop="bookvolume"
                    :label="recoveryTwo"
                    width="140px">
                <template slot-scope="scope">
                    <el-input v-model="scope.row.bookvolume" type="number"></el-input>
                </template>
            </el-table-column>

            <el-table-column
                    prop="bookborrower"
                    :label="recoveryThree"
                    width="150px">
                <template slot-scope="scope">
                    <el-input v-model="scope.row.bookborrower" type="number"></el-input>
                </template>
            </el-table-column>

            <el-table-column>
                <template slot-scope="scope">
                    <button @click="addLine"
                            class="addBtn"
                            v-if="scope.$index == tableData.length - 1">
                        <i class="el-icon-plus"></i>
                    </button>

                    <button v-if="tableData.length > 1"
                            @click="handleDelete(scope.$index, scope.row)"
                            class="del-btn">
                        <i class="el-icon-minus"></i>
                    </button>
                </template>
            </el-table-column>
        </el-table>
export default {
    data() {
        return {
            tableData:[{
                bookname: '',
                bookborrower: '',
                bookvolume:''
            }]
        }
    },
    methods:{
        addLine(){ //添加行数
            var newValue = {
                  bookname: '',
                  bookborrower: '',
                  bookvolume:''
              };
            //添加新的行数
            this.tableData.push(newValue);
        },
        handleDelete(index){ //删除行数
            this.tableData.splice(index, 1)
        },
        save(){
          //这部分应该是保存提交你添加的内容
          console.log(JSON.stringify(this.tableData))
        }
    }
 }


分享到:

扫描二维码推送至手机访问。

版权声明:本文由云河空间发布,如需转载请注明出处。

本文链接:http://yuyunhe.cn/index.php/post/299.html

分享给朋友:

“element table 表格添加行,删除行记录” 的相关文章

月薪3万的程序员都避开了哪些坑

月薪3万的程序员都避开了哪些坑

程序员薪水有高有低,有的人一个月可能拿30K、50K,有的人可能只有2K、3K。同样有五年工作经验的程序员,可能一个人每月拿20K,一个拿5K。是什么因素导致了这种差异?我特意总结了容易导致薪水低的九大行为表现,避开这些大坑,你就离高薪不远了。习惯即刻回报他不懂得只有春天播种,秋天才会有收获。刚刚付...

解决在微信内分享第三方链接标题、图片、摘要、链接等问题

<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script> <script> var imgUrl = docum...

Mysql 触发器使用(含navicat使用案例)

Mysql 触发器使用(含navicat使用案例)

CREATE TRIGGER updateutime2 BEFORE UPDATE on yp_cms_score for EACH ROW BEGIN  SET NEW.utime= ...

MySQL获得当前日期时间\时间戳函数

MySQL获得当前日期时间\时间戳函数 1.1 获得当前日期+时间(date + time)函数:now()mysql> select now();+———————+| now() |+———————+| 2008-08-08 22:20:46 |+———————+除了 now()...

多行文字溢出[...]的实现(text-overflow: ellipsis)

多行文字溢出[...]的实现(text-overflow: ellipsis)

对于单行文字, 很简单. Css代码  .oneLine {      width: 200px;      overflow:&...

RSA密钥的生成与配置(支付宝公私密钥可用)

RSA密钥的生成与配置(支付宝公私密钥可用)

RSA密钥的生成与配置openssl下载地址http://dldx.csdn.net/fd.php?i=20313208579480&s=ac2e809e168f7d5b8bf1515d3d6b1aa4,或者官方下载通过openssl工具生成RSA的公钥和私钥(opnssl工具可在互联网中下...

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。