当前位置:网站首页>El - tree set using setCheckedNodessetCheckedKeys default check nodes, and a new check through setChecked specified node
El - tree set using setCheckedNodessetCheckedKeys default check nodes, and a new check through setChecked specified node
2022-08-03 07:03:00 【m0_67391121】
Achieve the goal: When generating el-tree, select some of these options by default; or when selecting an option, select another option at the same time.
Achievement effect:
When generating a tree structure, two of these options are checked by default.
When one option is checked, the other option is also checked.

Implementation method:
First, set the default check when generating el-tree: two methods
1. Setting through node
setCheckedNodes
Set the currently checked node, use this method must set the node-key attribute
(nodes) Receive an array of checked node data
setCheckedNodes() {this.$refs.tree.setCheckedNodes([{id: 5,label: 'Secondary 2-1'}, {id: 9,label: 'Level 3 1-1-1'}]);},2. Set by key: the inside is an array
setCheckedKeys
Set the currently checked node through keys, the node-key attribute must be set to use this method
(keys, leafOnly) receives two parameters, 1. The array of keys of the selected node 2. The parameter of boolean type, if it is true, only the selected state of the leaf node is set, the default valueis false
setCheckedKeys() {this.$refs.tree.setCheckedKeys([3, 5]);},Second, when one option is checked, another option is also checked by default
The event triggered by checking an option is:
check-change
Callback when the selected state of the node changes
There are three parameters, in order: the object corresponding to the node in the array passed to the data attribute, whether the node itself is selected, and whether there is a selected node in the subtree of the node
Another option is also checked by default:
setChecked
Set the check state of a node through key / data, the node-key attribute must be set to use this method
(key/data, checked, deep) Receive three parameters, 1. Check the key or data of the node 2. boolean type, whether the node is selected 3. boolean type, whether to set the child node, the default is false
handleCheckChange(data, checked, indeterminate) {checked ? this.aMethods(data, true) : this.aMethods(data, false)},aMethods(item,bool){if(bool){this.$refs.tree.setChecked(5, true)}else{this.$refs.tree.setChecked(5, false)}}This achieves the above effect.For more information, please refer to the Element official website.
Let me introduce myself first. The editor graduated from Shanghai Jiaotong University in 2013. I worked in a small company and went to big factories such as Huawei and OPPO. I joined Alibaba in 2018, until now.I know that most junior and intermediate java engineers want to upgrade their skills, they often need to explore their own growth or sign up to study, but for training institutions, the tuition fee is nearly 10,000 yuan, which is really stressful.Self-learning that is not systematic is very inefficient and lengthy, and it is easy to hit the ceiling and the technology stops.Therefore, I collected a "full set of learning materials for java development" for everyone. The original intention is also very simple. I hope to help friends who want to learn by themselves but don't know where to start, and at the same time reduce everyone's burden.Add the business card below to get a full set of learning materials
边栏推荐
猜你喜欢
随机推荐
置顶文章-
empty() received an invalid combination of arguments - got (tuple, dtype=NoneType, device=NoneType),
配置MSTP功能示例
JUC并发编程深入浅出!
linux安装mysql
ClickHouse 数据插入、更新与删除操作 SQL
MySQL之concat的用法
超全!9种PCB表面处理工艺大对比
DIFM network, rounding and repetition
Servlet详解含实例
保姆级讲解Transformer
AQS、CAS、Synchronized小理解
Autowired注解与Resource注解的区别
【GIoU loss】GIoU loss损失函数理解
QT 连续生成指定范围内不重复的随机值
Redis的应用详解
Chrome插件开发入门
Multi-Head-Attention原理及代码实现
【nohup】nohup命令的简单使用
MySQL的DATE_FORMAT()函数将Date转为字符串









