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

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))
        }
    }
 }


分享到:

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

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

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

分享给朋友:

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

SVN Skipped 'xxx' -- Node remains in conflict 错误的解决办法

svn提交发现错误#cd /home/svn/app/# svn upUpdating '.':Skipped 'xxx' -- Node remains in conflictAt revision 1054.Summary of conflicts: ...

Thinkphp3.2.x 多图上传几个注意点

1、<form enctype="multipart/form-data">2、<form enctype="multipart/form-data">3、<input type="file...

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

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

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

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

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

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

css做屏幕适配

CSS判断不同分辨率浏览器(显示屏幕)显示不同宽度布局CSS3技术支持IE6到IE8。将用到css3 @media样式进行判断,但IE9以下版本不支持CSS3技术,这里DIVCSS5给大家介绍通过JS实现低版本的浏览器也支持CSS3实现实用布局CSS DIV网页布局中当分辨率小于等于1024px(像...

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

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

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

发表评论

访客

看不清,换一张

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