当前位置:网站首页>All expansion and collapse of a-tree
All expansion and collapse of a-tree
2022-07-05 22:26:00 【Short and brilliant】
ant-design-vue Trees a-tree It is necessary to realize the function of all expansion and all retraction
this.$refs.tree.store This data is printed out , Inside expanded Is to control the function of expanding and folding
\
Code implementation :
<div class="expand">
<a-button size="small" @click="expandHandle">{
{
expandAll ? " Put it all away " : " Expand all "
}}</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 Method
expandHandle() {
console.log(this.$refs.tree.store);
this.expandAll = !this.expandAll;
this.expandNodes(this.$refs.tree.store.root);
},
// Traverse tree data , Set the expanded attribute , Realize expansion and collapse
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]);
}
}
},
边栏推荐
- 元宇宙中的三大“派系”
- Oracle views the data size of a table
- Analysis of the problem that the cookie value in PHP contains a plus sign (+) and becomes a space
- How can Bluetooth in notebook computer be used to connect headphones
- Golang writes the opening chapter of selenium framework
- Granularity of blocking of concurrency control
- Go language learning tutorial (XV)
- Type of fault
- Nacos installation and service registration
- Pl/sql basic case
猜你喜欢
The difference between MVVM and MVC
Granularity of blocking of concurrency control
Sentinel production environment practice (I)
Talking about MySQL index
Sparse array [matrix]
Metaverse ape received $3.5 million in seed round financing from negentropy capital
Storage optimization of performance tuning methodology
Leetcode simple question: find the nearest point with the same X or Y coordinate
Concurrency control of performance tuning methodology
Promql demo service
随机推荐
[groovy] groovy dynamic language features (automatic type inference of function arguments in groovy | precautions for function dynamic parameters)
Analysis of the problem that the cookie value in PHP contains a plus sign (+) and becomes a space
Sentinel production environment practice (I)
2022-07-05:给定一个数组,想随时查询任何范围上的最大值。 如果只是根据初始数组建立、并且以后没有修改, 那么RMQ方法比线段树方法好实现,时间复杂度O(N*logN),额外空间复杂度O(N*
Learning of mall permission module
How to develop and introduce applet plug-ins
Win11运行cmd提示“请求的操作需要提升”的解决方法
Solutions for unexplained downtime of MySQL services
Common interview questions of JVM manufacturers
Platformio create libopencm3 + FreeRTOS project
2022软件测试工程师涨薪攻略,3年如何达到30K
Concurrency control of performance tuning methodology
Database tuning solution
Leetcode simple question: find the nearest point with the same X or Y coordinate
Granularity of blocking of concurrency control
50. Pow(x, n). O(logN) Sol
Leetcode simple question ring and rod
Analyse des risques liés aux liaisons de microservices
Lightweight dynamic monitorable thread pool based on configuration center - dynamictp
科技云报道:算力网络,还需跨越几道坎?