当前位置:网站首页>The El tree implementation only displays a certain level of check boxes and selects radio
The El tree implementation only displays a certain level of check boxes and selects radio
2022-04-23 15:27:00 【Elegant pig】
In fact, after this thing is made , It's quite simple .
Let's talk about the idea of implementation first :
Show only one level of check boxes :el-tree Provided in disabled attribute , When we set... For a node disabled After attribute , Then the current node is disabled , So let's find and add disabled The class name of the node check box , adopt display:none Just hide it , I've already found it here , The code is posted below .
The radio : You all know that there are many check boxes , But demand is always unsatisfactory , You have to choose a single choice , It's not hard . After the election , Get the currently selected node object , Then reset the selected node ( Only the currently selected nodes are set , Single choice )
The key codes are as follows :
el-tree: Components
Note here that it is best to set node-key Otherwise, something might go wrong
<el-tree
:data="treeData"
:props="{ children: 'children', label: 'label' }"
show-checkbox
@check-change="checkChange"
ref="Tree"
:check-strictly="true"
node-key="id"
></el-tree>
After getting the tree data from the back end :
Because I can only choose the innermost layer here ( No children The hierarchy of ) So add... Recursively disabled attribute , No, children Do not add
// Get the right tree data
getTreeList() {
/**
* ajax Got the data and this.treeData = data.data
* After acquisition
*/
this.setDisabled(this.treeData)
},
// Xiang you children Add... On the node of disabled attribute
setDisabled(treeData) {
treeData.forEach(item => {
if(item.children && item.children.length) {
item.disabled = true
this.setDisabled(item.children)
}
})
},
then css:
Just set this here , There are disabled Property will not display the check box
/* Hide el-tree There is disabled Attribute frame */
/deep/.el-checkbox__input.is-disabled{
display: none;
}
Then you can only choose one :
// Select the check box to trigger
checkChange(currObj,isChecked) {
if(isChecked) { // After selecting, we will reset the selected node ( Only the currently selected nodes are set , Single choice )
this.$refs.Tree.setCheckedNodes([currObj])
}
},
effect :

版权声明
本文为[Elegant pig]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231523549534.html
边栏推荐
- T2 icloud calendar cannot be synchronized
- Educational codeforces round 127 A-E problem solution
- Functions (Part I)
- Modify the default listening IP of firebase emulators
- Machine learning - logistic regression
- Squid agent
- JS - implémenter la fonction de copie par clic
- 函数(第一部分)
- Deep learning - Super parameter setting
- Hj31 word inversion
猜你喜欢

Five data types of redis

Mysql database explanation (10)

自主作业智慧农场创新论坛

8.4 realization of recurrent neural network from zero

函数(第一部分)
![Design of digital temperature monitoring and alarm system based on DS18B20 single chip microcomputer [LCD1602 display + Proteus simulation + C program + paper + key setting, etc.]](/img/c6/5241de0d670da3dae136a3047c6160.jpg)
Design of digital temperature monitoring and alarm system based on DS18B20 single chip microcomputer [LCD1602 display + Proteus simulation + C program + paper + key setting, etc.]

About UDP receiving ICMP port unreachable

Openstack command operation

激活函数的优缺点和选择

My raspberry PI zero 2W toss notes to record some problems and solutions
随机推荐
群体智能自主作业智慧农场项目启动及实施方案论证会议
Tun equipment principle
网站某个按钮样式爬取片段
T2 icloud calendar cannot be synchronized
Kubernetes详解(九)——资源配置清单创建Pod实战
Have you learned the basic operation of circular queue?
激活函数的优缺点和选择
调度系统使用注意事项
How to design a good API interface?
Application of skiplist in leveldb
Design of digital temperature monitoring and alarm system based on DS18B20 single chip microcomputer [LCD1602 display + Proteus simulation + C program + paper + key setting, etc.]
The life cycle of key value in redis module programming
JUC学习记录(2022.4.22)
Use of common pod controller of kubernetes
Precautions for use of dispatching system
Squid agent
我的 Raspberry Pi Zero 2W 折腾笔记,记录一些遇到的问题和解决办法
MySQL InnoDB transaction
Detailed explanation of C language knowledge points - data types and variables [2] - integer variables and constants [1]
kubernetes之常用Pod控制器的使用