vue+elementUI+表格,实现输入框失去焦点获取当前id和当前输入框改变的内容

实现的效果:

在这里插入图片描述

步骤:
一. html代码
 <!-- 用户列表表格 -->
    <div class="user-list-table">
      <el-table :data="tableData" stripe style="width: 100%">
        <el-table-column prop="userId" label="序号"> </el-table-column>
        <el-table-column prop="userName" label="昵称" width="">
        </el-table-column>
        <el-table-column prop="serialNumber" label="手机号" width="">
        </el-table-column>
        <el-table-column prop="createTime" label="加入日期" width="">
        </el-table-column>
        <el-table-column prop="levName" label="合伙人等级" width="">
        </el-table-column>
        <el-table-column prop="orderCount" label="订单数" width="">
        </el-table-column>
        <el-table-column label="可用积分" width="">
          <template slot-scope="scope">
            <el-input
              v-model="scope.row.scoreValue"
              @blur="handch(scope.row.userId,scope.row.scoreValue)"
            ></el-input>
          </template>
        </el-table-column>
        <el-table-column label="合伙人团队" width="">
          <template slot-scope="scope">
            <el-button size="small" class="team">查看</el-button>
          </template>
        </el-table-column>
        <el-table-column label="收货地址" width="">
          <template slot-scope="scope">
            <el-button size="small" class="site">查看</el-button>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="">
          <template slot-scope="scope">
            <el-button size="small" class="blacklist">拉黑</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
二. css(less)代码
  .content {
    height: 710px;
    width: 100%;
    background-color: #fff;
    box-shadow: 2px 2px 5px #e6e6e6;
    padding: 0 14px;
    box-sizing: border-box;
    overflow-x: auto;
    .user-list-table {
      .el-table__header-wrapper {
        .has-gutter {
          tr {
            th {
              background-color: #f5faff;
              text-align: center;
              color: #0085f4;
              font-size: 16px;
              .cell {
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
              }
            }
          }
        }
      }
      tbody {
        .el-table__row {
          td {
            text-align: center;
            padding: 10px 0px;
            .cell {
              overflow: hidden;
              text-overflow: ellipsis;
              white-space: nowrap;
              .el-button {
                padding: 6px 20px;
                font-size: 16px;
                &.team {
                  background-color: #0085f4;
                  color: #fff;
                }
                &.site {
                  background-color: #fff;
                  color: #000;
                  border-color: #0085f4;
                }
                &.blacklist {
                  background-color: #ccc;
                  color: #000;
                }
              }
            }
          }
        }
      }
    }
  }
三. js代码
export default {
   data() {
    return {
      tableData: [
         {
          createTime: '2019-09-23',
          levName: '铜',
          orderCount: 0,
          scoreValue: '2',
          serialNumber: '10000',
          status: '1',
          userId: '10',
          userName: '测试1'
        }
      ],  // 用户列表数据
      changeId: '' // 改变的值
    },
     methods: {
     handch(item, id) {
      console.log('我是id:', item, ',我是需要改变的值:', id)
        }
     }
  },
  • 1
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值