当前位置:网站首页>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),
- 【OpenStack云平台】搭建openstack云平台
- pyspark df 二次排序
- 国内首款PCB资料分析软件,华秋DFM使用介绍
- JUC并发编程深入浅出!
- PCB 多层板为什么都是偶数层?
- cnpm的安装与使用
- 【onnx 输入尺寸】修改pytorch生成的onnx模型的输入尺寸
- El - table column filter functions, control columns show and hide (effect and easy to implement full marks)
- 【英语单词】常见深度学习中编程用到的英语词汇
猜你喜欢
随机推荐
PHP Composer常用命令积累
Chrome插件开发入门
我的Go+语言初体验——祝福留言小系统,让她也可以感受到你的祝福
linux安装mysql
MySql之json_extract函数处理json字段
cnpm的安装与使用
SQL——左连接(Left join)、右连接(Right join)、内连接(Inner join)
Getting started with el-tabs (tab bar)
MySQL之DQL——查询语言
【云原生 · Kubernetes】Kubernetes基础环境搭建
【nohup】nohup命令的简单使用
信息学奥赛一本通T1453:移动玩具
SQLSERVER将子查询数据合并拼接成一个字段
零代码工具拖拽流程图
mysql慢查询优化
JUC并发编程深入浅出!
process.env环境变量配置方式(配置环境变量区分开发环境和生产环境)
el-tree设置选中高亮焦点高亮、选中的节点加深背景,更改字体颜色等
MySQL的安装教程(嗷嗷详细,包教包会~)
记一次postgresql中使用正则表达式








