当前位置:网站首页>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]);
}
}
},
边栏推荐
- Metaverse Ape上线倒计时,推荐活动火爆进行
- Golang writes the opening chapter of selenium framework
- Win11运行cmd提示“请求的操作需要提升”的解决方法
- Official clarification statement of Jihu company
- Decorator learning 01
- "Chris Richardson microservices series" uses API gateway to build microservices
- Sentinel production environment practice (I)
- Summary of concurrency control
- A long's perception
- Solutions for unexplained downtime of MySQL services
猜你喜欢
![[error record] file search strategy in groovy project (src/main/groovy/script.groovy needs to be used in the main function | groovy script directly uses the relative path of code)](/img/b6/b2036444255b7cd42b34eaed74c5ed.jpg)
[error record] file search strategy in groovy project (src/main/groovy/script.groovy needs to be used in the main function | groovy script directly uses the relative path of code)

Matlab draws a cute fat doll

Summary of concurrency control

The statistics of leetcode simple question is the public string that has appeared once

Talking about MySQL index

装饰器学习01

Countdown to 92 days, the strategy for the provincial preparation of the Blue Bridge Cup is coming~

Calculation method of boundary IOU

50. Pow(x, n). O(logN) Sol

Meituan dynamic thread pool practice ideas, open source
随机推荐
极狐公司官方澄清声明
50. Pow(x, n). O(logN) Sol
Analyse des risques liés aux liaisons de microservices
Three "factions" in the metauniverse
实战:fabric 用户证书吊销操作流程
QT creator 7-cmake update
Performance testing of software testing
Understand the basic concept of datastore in Android kotlin and why SharedPreferences should be stopped in Android
The simple problem of leetcode is to split a string into several groups of length K
Interprocess communication in the "Chris Richardson microservice series" microservice architecture
Leetcode simple question ring and rod
Business learning of mall order module
如何创建线程
Storage optimization of performance tuning methodology
[error record] groovy function parameter dynamic type error (guess: groovy.lang.missingmethodexception: no signature of method)
Oracle hint understanding
Overriding equals() & hashCode() in sub classes … considering super fields
344. Reverse String. Sol
Draw a red lantern with MATLAB
Meituan dynamic thread pool practice ideas, open source