el-table数据渲染 点击按钮 实现不刷新 呈现数据状态

实践文章

个人开发问题,记录一下,可能会存在不完美,欢迎大佬追加!!!,

html片段 重点 标记- - ->动态显示区域

 <!-- 列表 -->
    <el-table :data="tableData" border style="width: 100%">
      <el-table-column fixed prop="user_name" label="姓名"></el-table-column>
      <el-table-column prop="user_code" label="编码"></el-table-column>
      <el-table-column prop="need_recheck" label="验证状态">
       <!--动态显示区域--> 
        <template slot-scope="scope">
          <el-button type="info" plain disabled  class="status1" size="mini" >{{scope.row.need_recheck !=1 ? "已关闭" :"已开启"}}</el-button>   
        </template>
      </el-table-column>
      <el-table-column fixed="right" label="操作" width="230">
        <template slot-scope="scope">
        <!--scope.$index  获取触发事件的行-->
          <el-button @click="handleClick(scope.row,scope.$index)" size="mini" type="success">开启</el-button>
          <el-button @click="closeClick(scope.row,scope.$index)" size="mini" type="danger">关闭</el-button>
          <el-button @click="resetSafety(scope.row)" type="primary" size="mini">重置</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
  

js 代码 $set方法

 handleClick(row, index) {
      console.log(row, index, "开启操作");

      var index1 = index;
      var userCode = row.user_code;
      var that = this;
      this.$http.ajax({
        url: that.$api.config.addSafety,
        method: "post",
        data: {
          need_recheck: 1,
          user_code: userCode
        },
        success(res) {
          if (res.data.code == 0) {
          // $set方法
             that.$set(that.tableData[index1],'need_recheck',1);
            // that.aaa();
          }
        }
      });
    },

显示结果

图片: 在这里插入图片描述
点击按钮 开启关闭 按钮 实现不刷新 呈现数据状态

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值