el-table自定义表头 ,表头控制数据的展示与隐藏

在这里插入图片描述
在这里插入图片描述

<el-table ref="multipleTable" :data="tableDataNo" tooltip-effect="dark"  :class="tableHeaderUpOn == '展开' ? 'hideScrollNode' : ''"  >
          <el-table-column type="selection" width="60" align="center"> </el-table-column>
          <el-table-column :label="未学习">
            <template slot="header" slot-scope="scope">
              <i :class="tableHeaderUpOn == '展开' ? 'el-icon-caret-right' : 'el-icon-caret-bottom' " @click="tableDataNoClick"></i> {{'未学习'}}
            </template>
            <template slot-scope="scope">
              <el-tooltip class="item" effect="dark" :content="scope.row.ruleName" placement="top">
                <div style="cursor:pointer;overflow: hidden; text-overflow: ellipsis; white-space: nowrap;" @click="gotoBasisListAdd(scope.row)">
                  {{scope.row.ruleName}}
                </div>
              </el-tooltip>
              <div>
                <el-row>
                  <el-col :span="6" style="padding-right:5px;">
                    <div>职务岗位:{{scope.row.jobPosition}}</div>
                  </el-col>
                  <el-col :span="6" style="padding-right:5px;">
                    <div>清单分类:{{scope.row.comName}}</div>
                  </el-col>
                </el-row>
              </div>

            </template>
          </el-table-column>
        </el-table>
 tableDataNo: [
        {
          id: 30,
          ruleName: "sidjfaoiund",
          jobPosition: "dsagddsfgv",
          comName: "dsafsdfds",
          createTime: "sdafds",
          learningState: "sdzfdsf",
         
        },
      ],
      tableHeaderUpOn: "展开",
    tableDataNoClick() {
      if (this.tableHeaderUpOn == "展开") {
        this.tableHeaderUpOn = "收起"
      } else {
        this.tableHeaderUpOn = "展开"
      }
    },
<style>
.hideScrollNode .is-scrolling-none {
  display: none;
}
</style>

完结

补充:

  <el-table-column
            label="全选"
            :render-header="(h, obj) => renderHeader(h, obj, '确定')"
            style="display: inline"
          > </el-table-column>
    // 自定义列名
    renderHeader(h, { column, $index }, type) {
      let that = this;
      return h("div", [
        // 列名称
        h("span", column.label),
        // 按钮
        h(
          "el-button",
          {
            props: {
              type: "primary",
              // size: 'small',
            },
            class: "el-icon-download",
            style: "margin-left: 15px;background:#169BD5;width:136px;",
            on: {
              click: function () {
                // that.clickButton(type);
              },
            },
          },
          "批量下载"
        ),
      ]);
    },
    clickButton(){
    },
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值