当前位置:网站首页>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]);
}
}
},
边栏推荐
- 科技云报道荣膺全球云计算大会“云鼎奖”2013-2022十周年特别贡献奖
- Practice: fabric user certificate revocation operation process
- [agc009e] eternal average - conclusion, DP
- Serializability of concurrent scheduling
- [Chongqing Guangdong education] National Open University autumn 2018 0088-21t Insurance Introduction reference questions
- MySQL连接断开报错MySQLdb._exceptions.OperationalError 4031, The client was disconnected by the server
- How to reverse a string fromCharCode? - How to reverse String. fromCharCode?
- 了解 Android Kotlin 中 DataStore 的基本概念以及为什么应该停止在 Android 中使用 SharedPreferences
- 航海日答题小程序之航海知识竞赛初赛
- Index optimization of performance tuning methodology
猜你喜欢
What if win11 is missing a DLL file? Win11 system cannot find DLL file repair method
点到直线的距离直线的交点及夹角
Concurrency control of performance tuning methodology
Nacos installation and service registration
Granularity of blocking of concurrency control
[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)
Common interview questions of redis factory
Learning of mall permission module
Serializability of concurrent scheduling
Storage optimization of performance tuning methodology
随机推荐
Database recovery strategy
opencv 判断点在多边形内外
Granularity of blocking of concurrency control
Blocking of concurrency control
509. Fibonacci Number. Sol
Leetcode simple question: the minimum cost of buying candy at a discount
Create a virtual machine on VMware (system not installed)
Pl/sql basic syntax
Understand the basic concept of datastore in Android kotlin and why SharedPreferences should be stopped in Android
Evolution of large website architecture and knowledge system
QT creator 7-cmake update
Leetcode simple question: find the nearest point with the same X or Y coordinate
Oracle is sorted by creation time. If the creation time is empty, the record is placed last
Microservice link risk analysis
Stored procedures and stored functions
C language - structural basis
1.3 years of work experience, double non naked resignation agency face-to-face experience [already employed]
2022-07-05:给定一个数组,想随时查询任何范围上的最大值。 如果只是根据初始数组建立、并且以后没有修改, 那么RMQ方法比线段树方法好实现,时间复杂度O(N*logN),额外空间复杂度O(N*
Countdown to 92 days, the strategy for the provincial preparation of the Blue Bridge Cup is coming~
Some tutorials install the database on ubantu so as not to occupy computer memory?