el-table悬停当前行,显示当前行操作按钮,取消当前行悬停,当前行按钮隐藏

<el-table
      @cell-mouse-enter="hoverRow"
      v-if="tableData.length > 0"
      @cell-mouse-leave="leaveRow"//关键
      @sort-change="sortChange"//关键
      :header-cell-style="{'text-align':'center'}"
      :cell-style="{'text-align':'center'}"
      class="table-style"
      :data="tableData"
    >
<el-table-column>
	 <templateslot-scope="scope">
	   <div style="color:#ffbf00;" v-show="scope.row.showRightOp">//关键
	     <span v-if="scope.row.partnerInfo.status == '1'">
	       <span @click="partnerOp(2,scope.row.partnerInfo.userId)" style="cursor: pointer;">注销</span>
	     </span>
	     <span v-if="scope.row.partnerInfo.status == '2'">
	       <span @click="partnerOp(1,scope.row.partnerInfo.userId)" style="cursor: pointer;">启用</span>
	       <span @click="partnerOp(0,scope.row.partnerInfo.userId)" style="margin-left:40px;cursor: pointer;">删除</span>
	     </span>
	   </div>
	 </template>
</el-table-column>
    getTableData() {
      this.tableData = [];
      let req = {
        curPage: this.currentPage,
        pageSize: this.pageSize,
        startDate: this.pickerVal[0],
        endDate: this.pickerVal[1],
        partnerName: this.inputVal,
        orderBy: this.orderBy,
        orderType: this.orderType
      };
      this.$axios
        .get("/manage/partner/info/list", { params: req })
        .then(resp => {
          if (resp.data.responseCode == 200) {
            if (resp.data.data) {
              this.tableData = resp.data.data;//请求表格数据,拿到tableData 
              this.totalNum = resp.data.totalCount;
              this.tableData.map((item, index) => {
                item.showRightOp = false;  //需要先在tableData数组中每个元素添加showRightOp为false
              });
            }
          }
        });
    },
hoverRow(row) {
  row.showRightOp = true;
  this.$set(this.tableData, row.index, row);
},
leaveRow(row) {
  row.showRightOp = false;
  this.$set(this.tableData, row.index, row);
},

在这里插入图片描述

  • 2
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值