将树结构,统一按钮,点击展开和收起
<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;
});
},