elementUI+vue 组件 表格嵌套

一. 表格嵌套

          代码段:

  <el-table
      :data="tableData5"
      :row-key="getRowKeys"
      :expand-row-keys="expands"
      style="width: 100%">
      <el-table-column type="expand">  //type="expand" 带下层数据的字段
        <template scope="scope">
        <el-table class="demo-table-expand"
                  :data="scope.row.tableData3"
                    border
                    style="width: 100%">
            <el-table-column
              prop="tableData3.date"
              label="编号"
            >
            </el-table-column>
            <el-table-column
              prop="name"
              label="房间号"
            >
            </el-table-column>
            <el-table-column
              prop="name"
              label="房型">
            </el-table-column>
            <el-table-column
              prop="date"
              label="性别"
            >
            </el-table-column>
            <el-table-column
              prop="name"
              label="总床位"
            >
            </el-table-column>
            <el-table-column
              prop="address"
              label="状态">
            </el-table-column>
            <el-table-column
              prop="date"
              label="备注"
            >
            </el-table-column>
            <el-table-column align="center" label="操作" width="150">
              <template scope="scope">
                <el-button size="small" type="success" @click="handleUpdate(scope.row)">修改
                </el-button>
                <el-button size="small" type="danger" @click="sure">删除
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </template>
      </el-table-column>
      <el-table-column align="center"
                       label="楼宇"
                       prop="names">
      </el-table-column>
      <el-table-column align="center"
                       label="描述"
                       prop="desc">
      </el-table-column>
      <el-table-column align="center" label="操作" width="150">
        <template scope="scope">
          <el-button size="small" type="success" @click="handleUpdate(scope.row)">修改
          </el-button>
          <el-button size="small" type="danger" @click="sure">删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

 

数据格式:

tableData5: [{
              names: 'S1-科技楼',
              desc: '公司楼',
              tableData3: [{
                  date: '2016-05-03',
                  name: '王小虎',
                  address: '上海市普陀区金沙江路 1518 弄'
              }]
          },
          {
              names: 'S2-科技楼',
              desc: '上课喽',
              tableData3: [{
                  date: '2016-05-03',
                  name: '张小虎',
                  address: '上海市普陀区金沙江路 32421弄'
              }]
          }],`

 

效果图:

//添加数据

this.list.unshift(this.temp);

//删除数据

const index = this.list.indexOf(row); //找到要删除数据在list中的位置 this.list.splice(index, 1); //通过splice 删除数据

//修改数据

const index = this.list.indexOf(row); //找到修改的数据在list中的位置

this.list.splice(index, 1,this.updatedData); //通过splice 替换数据 触发视图更新

 

参考网址:https://juejin.im/post/593121aa0ce4630057f70d35#heading-18

https://segmentfault.com/q/1010000011699125


 

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值