当前位置:网站首页>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
边栏推荐
猜你喜欢
Nacos与Eureka的区别
SQL——左连接(Left join)、右连接(Right join)、内连接(Inner join)
ES6 - 剩余参数,Array的扩展方法,String的扩展方法
AQS、CAS、Synchronized小理解
置顶文章-
Content type ‘applicationx-www-form-urlencoded;charset=UTF-8‘ not supported“【已解决】
pyspark---对suuid区间编码(基于曝光数、点击数)
mysql 时间字段默认设置为当前时间
【dllogger bug】AttributeError: module ‘dllogger‘ has no attribute ‘StdOutBackend‘
【设计指南】避免PCB板翘,合格的工程师都会这样设计!
随机推荐
CPU上下文切换详解思维导图
【地平线 开发板】实现模型转换并在地平线开发板上部署的全过程操作记录(魔改开发包)
VO、DTO、DO、POJO的区别和概念
Docker安装Mysql
【GIoU loss】GIoU loss损失函数理解
sql优化常用的几种方法
SQLSERVER将子查询数据合并拼接成一个字段
【云原生 · Kubernetes】Kubernetes简介及基本组件
国内首款PCB资料分析软件,华秋DFM使用介绍
【Markdown 数学公式】markdown常用公式写法
链表之打基础--基本操作(必会)
如何使用md5码验证文件的一致性
MySQL 操作语句大全(详细)
IFM network detailed explanation and torch reproduction
cnpm的安装与使用
Shell脚本--信号发送与捕捉
MySQL的安装(详细教程)
我的Go+语言初体验——祝福留言小系统,让她也可以感受到你的祝福
10 common data types in MySQL
计算机网络高频面试考点