baozhengrui

导航

将树结构,统一按钮,点击展开和收起

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

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



 // 是否展开,默认全部展开
      isExpandAll: true,



/** 展开/折叠操作 */
    toggleExpandAll() {
      this.refreshTable = false;
      this.isExpandAll = !this.isExpandAll;
      this.$nextTick(() => {
        this.refreshTable = true;
      });
    },


posted on 2023-10-23 14:39  芮艺  阅读(38)  评论(0编辑  收藏  举报