您的位置:首页 > 健康 > 养生 > el-table 树状表格展开及折叠

el-table 树状表格展开及折叠

2024/10/5 22:28:08 来源:https://blog.csdn.net/sinat_34896766/article/details/140145491  浏览:    关键词:el-table 树状表格展开及折叠

在工作中,可能需要对树状表格进行全部折叠及全部展开,可采用以下方法: 

页面内容如下:

<el-table v-if="refTable" :data="list" row-key="id" :tree-props="{children:'children',hasChildren:'hasChildren'" :default-expand-all="isExpand"><el-table-column label="机构名称" prop="attributes.org_name"></el-table-column>
</el-table>

数据格式如下:

    data() {return {data: [{attributes:[org_name:'1'],hasChildren: true,label: '一级 1',children: [{attributes:[org_name:'1'],hasChildren: true,label: '二级 1-1',children: [{attributes:[org_name:'1'],hasChildren: false,label: '三级 1-1-1'}]}]}],};},

具体方法如下:

handleExpand() {this.refTable = falsethis.isExpand = !this.ieExpandthis.$nextTick(() => {this.refTable = true})
}

 

 

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com