当前位置:网站首页>a-tree 树的全部展开和收起
a-tree 树的全部展开和收起
2022-07-05 22:20:00 【短暂又灿烂的】
ant-design-vue树a-tree需要实现全部展开和全部收起功能实现

this.$refs.tree.store 打印出来的是这样的数据,里面的expanded就是控制展开收起的功能
\
代码实现:
<div class="expand">
<a-button size="small" @click="expandHandle">{
{
expandAll ? "全部收起" : "全部展开"
}}</a-button>
</div>
<div class="func">
<span>name</span>
<span>value</span>
</div>
<a-tree
:data="treeData"
show-checkbox
node-key="id"
:default-expand-all="expandAll"
:default-expanded-keys="defaultExpandedKeys"
:expand-on-click-node="false"
ref="tree"
@check="handleCheck"
>
<span class="custom-tree-node" slot-scope="{ node, data }">
<span>{
{ node.label }}</span>
<span>{
{ data.type }}</span>
</span>
</a-tree>
methods方法
expandHandle() {
console.log(this.$refs.tree.store);
this.expandAll = !this.expandAll;
this.expandNodes(this.$refs.tree.store.root);
},
// 遍历树形数据,设置每一项的expanded属性,实现展开收起
expandNodes(node) {
node.expanded = this.expandAll;
for (let i = 0; i < node.childNodes.length; i++) {
node.childNodes[i].expanded = this.expandAll;
if (node.childNodes[i].childNodes.length > 0) {
this.expandNodes(node.childNodes[i]);
}
}
},
边栏推荐
- C language knowledge points link
- [Yugong series] go teaching course 003-ide installation and basic use in July 2022
- IIC bus realizes client device
- Shelved in TortoiseSVN- Shelve in TortoiseSVN?
- Draw a red lantern with MATLAB
- 70. Climbing Stairs. Sol
- Pl/sql basic case
- 344. Reverse String. Sol
- Some tutorials install the database on ubantu so as not to occupy computer memory?
- 科技云报道荣膺全球云计算大会“云鼎奖”2013-2022十周年特别贡献奖
猜你喜欢

Technology cloud report won the special contribution award for the 10th anniversary of 2013-2022 of the "cloud Ding Award" of the global cloud computing conference

Decorator learning 01

Server optimization of performance tuning methodology

Search: Future Vision (moving sword)

IIC bus realizes client device
![[Yugong series] go teaching course 003-ide installation and basic use in July 2022](/img/9d/7d01bc1daa61f6545f619b6746f8bb.png)
[Yugong series] go teaching course 003-ide installation and basic use in July 2022

数博会精彩回顾 | 彰显科研实力,中创算力荣获数字化影响力企业奖

Metaverse Ape上线倒计时,推荐活动火爆进行

2022软件测试工程师涨薪攻略,3年如何达到30K

MySQL disconnection reports an error MySQL ldb_ exceptions. OperationalError 4031, The client was disconnected by the server
随机推荐
Business learning of mall commodity module
科技云报道荣膺全球云计算大会“云鼎奖”2013-2022十周年特别贡献奖
Sentinel production environment practice (I)
Solutions for unexplained downtime of MySQL services
Qtquick3d real time reflection
Learning of mall permission module
[groovy] mop meta object protocol and meta programming (execute groovy methods through metamethod invoke)
Leetcode simple question ring and rod
Cobaltstrike builds an intranet tunnel
Lightweight dynamic monitorable thread pool based on configuration center - dynamictp
Analysis of the problem that the cookie value in PHP contains a plus sign (+) and becomes a space
Overview of concurrency control
装饰器学习01
What if the files on the USB flash disk cannot be deleted? Win11 unable to delete U disk file solution tutorial
The new content of the text component can be added through the tag_ Config set foreground and background colors
Calculation method of boundary IOU
Leetcode simple question: check whether each row and column contain all integers
2022-07-05: given an array, you want to query the maximum value in any range at any time. If it is only established according to the initial array and has not been modified in the future, the RMQ meth
Leetcode simple question: the minimum cost of buying candy at a discount
Bitbucket installation configuration