el-table展开行,点击展开接口获取数据,expand-row-keys获取展开项

<el-table :data="tableData" border @expand-change="expandChange" :row-key="rowKey" :expand-row-keys="expandRowKeys">
  <el-table-column type="expand">
    <template slot-scope="props">
       <div>{{props.expandList}}</div>
    </template>
  </el-table-column>
</el-table>

data() {
    return {
      expandRowKeys:[],
      tableData: []
     }
  },
  methods: {
    // 全部隐藏
    hanghide () {
      this.expandRowKeys = []
    },
    rowKey(row) {
      return row.id
    },
    expandChange(value, expandedRows) {
      request({}).then(res=> {
        this.$set(this.tableData[value.index],'expandList',res.data)
          this.formatData(this.tableData[value.index].expandList,value.type);
      }).catch(()=> {})
      this.expandRowKeys=expandedRows.map(item => item.orderNum);
    },
  }

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
根据提供的引用内容,我理解您的问题是关于el-table展开表格嵌套fix影响的解决方法。针对这个问题,我提供以下解决方案: 1. 首先,可以尝试使用el-tableexpand-row-keys属性来解决这个问题。该属性可以设置一个数组,其中包含需要展开key值。例如: ```html <el-table :data="tableData" :expand-row-keys="expandKeys"> <el-table-column prop="date" label="日期" width="180"></el-table-column> <el-table-column prop="name" label="姓名" width="180"></el-table-column> <el-table-column prop="address" label="地址"></el-table-column> <el-table-column label="操作"> <template slot-scope="scope"> <el-button size="mini" @click="handleExpand(scope.row)">展开</el-button> </template> </el-table-column> <el-table-column label="详情" v-if="showDetail"> <template slot-scope="scope"> <p>电话:{{ scope.row.tel }}</p> <p>邮箱:{{ scope.row.email }}</p> </template> </el-table-column> </el-table> ``` 在上面的代码中,我们使用了expand-row-keys属性来绑定一个数组expandKeys,其中包含需要展开key值。然后,在handleExpand方法中,我们可以将需要展开key值添加到expandKeys数组中,从而实现展开表格嵌套的效果。 2. 另外,如果您的el-table表格嵌套比较复杂,可以尝试使用scoped slot来自定义展开的内容。例如: ```html <el-table :data="tableData"> <el-table-column prop="date" label="日期" width="180"></el-table-column> <el-table-column prop="name" label="姓名" width="180"></el-table-column> <el-table-column prop="address" label="地址"></el-table-column> <el-table-column label="操作"> <template slot-scope="scope"> <el-button size="mini" @click="scope.row.showDetail = !scope.row.showDetail">展开</el-button> </template> </el-table-column> <el-table-column label="详情"> <template slot-scope="scope"> <div v-if="scope.row.showDetail"> <el-table :data="scope.row.detailData"> <el-table-column prop="tel" label="电话"></el-table-column> <el-table-column prop="email" label="邮箱"></el-table-column> </el-table> </div> </template> </el-table-column> </el-table> ``` 在上面的代码中,我们使用了scoped slot来自定义展开的内容。具体来说,我们在操作列中添加了一个按钮,然后在点击按钮时,将showDetail属性设置为true或false,从而控制展开的显示或隐藏。然后,在详情列中,我们使用了一个嵌套的el-table来展示详情数据。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值