当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
【EA Price strategy OC1】以实时价格为依据的EA,首月翻仓!】
mysql 数据去重的三种方式[实战]
10 common data types in MySQL
PCB 多层板为什么都是偶数层?
Chrome插件开发入门
信息学奥赛一本通T1449:魔板
Getting Started with Chrome Plugin Development
Docker安装Mysql
Redis哨兵模式+过期策略、淘汰策略、读写策略
MySQL必知必会
cookie和session区别
MySQL的DATE_FORMAT()函数将Date转为字符串
信息学奥赛一本通T1447:靶形数独
HDI与普通PCB的4点主要区别
Nacos单机模式的安装与启动
【YOLOv3 SPP 数据集准备】YOLOv3 SPP数据集准备代码理解
SQL——左连接(Left join)、右连接(Right join)、内连接(Inner join)
【设计指南】避免PCB板翘,合格的工程师都会这样设计!
MySQL 数据库基础知识(系统化一篇入门)
计算机网络高频面试考点








