element table type="expand" 设置成按钮展开,并且设置背景色

          <el-table
            ref="cargoTable"
            :data="cargoTransList"
            v-show="shipIndex==2"
            :header-cell-style="{background:'#F4F5F6',color:'#131D34',padding: '8px 0'}"
          >
   
            <el-table-column label="操作" width="150" align="center">
              <template slot-scope="scope">
                <el-button
                  type="primary"
                  icon="el-icon-phone"
                  plain
                  @click="toogleExpandCargo(scope.row)"
                >联系货主</el-button>
              </template>
            </el-table-column>
            <el-table-column type="expand" width="1">
              <template slot-scope="scope">
                <div>
                  <div>
                    <span
                      class="fr btn-font font-bold"
                      style="color:#2C72FC"
                    >{{scope.row.contactTelNo||'暂无'}}-{{scope.row.contactName}}</span>
                  </div>
                  <div class="contect-font" style="clear:both">
                    <span class="fr xs-sp-t" style="color:#2F3033">备注:{{ scope.row.remark||'暂无' }}</span>
                  </div>
                </div>
              </template>
            </el-table-column>
          </el-table>

上面主要要注意el-table ref的设置

methods:{
    toogleExpandCargo(row) {
      let $table = this.$refs.cargoTable;
      this.cargoTransList.map(item => {
        if (row.id != item.id) {
          $table.toggleRowExpansion(item, false);
        }
      });
      $table.toggleRowExpansion(row);
    },
}

还有就是设置隐藏列的背景色

.el-table >>> .el-table__expanded-cell[class*="cell"] {
  background: #f4f5f6;
}

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值