table的展开折叠按钮操作

按钮


        <el-button
          type="info"
          plain
          icon="el-icon-sort"
          size="mini"
          @click="toggleExpandAll"
          >展开/折叠</el-button
        >

table: default-expand-all=“isExpandAll”

<el-table
      v-if="refreshTable"
      v-loading="loading"
      :data="evalNormList"
      row-key="id"
      :default-expand-all="isExpandAll"
      :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
    >
    </el-table>

js

      // 重新渲染表格状态
      refreshTable: true,
      // 是否展开,默认全部展开
      isExpandAll: true,
/** 展开/折叠操作 */
    toggleExpandAll() {
      this.refreshTable = false
      this.isExpandAll = !this.isExpandAll
      this.$nextTick(() => {
        this.refreshTable = true
      })
    },

你可能感兴趣的:(前端,vue.js)