美文网首页
2018-09-10element-ui表格展开行每次只能展开一

2018-09-10element-ui表格展开行每次只能展开一

作者: 怪兽别跑biubiubi | 来源:发表于2018-09-10 10:17 被阅读0次
          <template>
            <el-table 
              @expand-change="expandSelect"
              type='index'
              :row-key='getRowKeys'
              :expand-row-keys="expands"
              :data="tableData" style="width: 100%"
              :default-sort = "{prop: 'payment_date', order: 'descending'}">
              <!-- 排序:default-sort sortable -->
              <el-table-column label="申请时间" prop="date_created" sortable align='left'></el-table-column>
              <el-table-column label="操作" align='left' width='100px'>
                <template slot-scope="scope">
                  <button class="btn" @click="handleEdit(scope.$index, scope.row)">查看</button>
                </template>
              </el-table-column>
              <!-- expand:折叠面板 -->
              <el-table-column type="expand">
                <template slot-scope="scope">
                  <div class="bottom_content">
                    折叠面板 type为expand。方法:@expand-change="expandSelect"
                    expand-change: 当用户对某一行展开或者关闭的时候会触发该事件
                  </div>
                </template>
              </el-table-column>
            </el-table>
          </template>
          <script>
          export default {
            data () {
              return {
                expands: [],
                getRowKeys (row) {
                  return row.id
                },
                tableData: []
              }
            },
            methods: {
              // 折叠面板每次只能展开一行
              expandSelect (row, expandedRows) {
                var that = this
                if (expandedRows.length) {
                  that.expands = []
                  if (row) {
                    that.expands.push(row.id)
                  }
                } else {
                  that.expands = []
                }
              },
              handleEdit (index, row) {}
            }
          }
          </script>
    

    相关文章

      网友评论

          本文标题:2018-09-10element-ui表格展开行每次只能展开一

          本文链接:https://www.haomeiwen.com/subject/jnbjgftx.html