当前位置:网站首页>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]);
}
}
},
边栏推荐
- 数博会精彩回顾 | 彰显科研实力,中创算力荣获数字化影响力企业奖
- Implementation technology of recovery
- Metaverse Ape上线倒计时,推荐活动火爆进行
- What changes has Web3 brought to the Internet?
- Bitbucket installation configuration
- When the industrial Internet era is truly mature, we will look at the emergence of a series of new industrial giants
- Damn, window in ie open()
- U盘的文件无法删除文件怎么办?Win11无法删除U盘文件解决教程
- Comment développer un plug - in d'applet
- 1.3 years of work experience, double non naked resignation agency face-to-face experience [already employed]
猜你喜欢
数据泄露怎么办?'华生·K'7招消灭安全威胁
Interview questions for famous enterprises: Coins represent a given value
Damn, window in ie open()
What changes has Web3 brought to the Internet?
A substring with a length of three and different characters in the leetcode simple question
Pl/sql basic syntax
"Chris Richardson microservices series" uses API gateway to build microservices
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
Getting started with microservices (resttemplate, Eureka, Nacos, feign, gateway)
50. Pow(x, n). O(logN) Sol
随机推荐
Daily question brushing record (XIV)
Oracle hint understanding
QT creator 7-cmake update
如何向mongoDB中添加新的字段附代码(全)
90后测试员:“入职阿里,这一次,我决定不在跳槽了”
點到直線的距離直線的交點及夾角
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
Matlab draws a cute fat doll
Stored procedures and stored functions
MySQL服务莫名宕机的解决方案
Recovery technology with checkpoints
A trip to Suzhou during the Dragon Boat Festival holiday
Performance monitoring of database tuning solutions
2022软件测试工程师涨薪攻略,3年如何达到30K
How to add new fields to mongodb with code (all)
Business learning of mall order module
MySQL连接断开报错MySQLdb._exceptions.OperationalError 4031, The client was disconnected by the server
Leetcode simple question: find the nearest point with the same X or Y coordinate
Platformio create libopencm3 + FreeRTOS project
Alternating merging strings of leetcode simple questions