当前位置:网站首页>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单机模式的安装与启动
- 2021新版idea过滤无用文件.idea .iml
- Redis-记一次docker下使用redis
- 一文读懂PCB品质体系认证
- Nacos下载与安装
- IFM network detailed explanation and torch reproduction
- Composer require 报错 Installation failed, reverting ./composer.json and ./composer.lock to their ...
- SQL——左连接(Left join)、右连接(Right join)、内连接(Inner join)
- 【nohup】nohup命令的简单使用
- 2021年PHP-Laravel面试题问卷题 答案记录
猜你喜欢
empty() received an invalid combination of arguments - got (tuple, dtype=NoneType, device=NoneType),
ES6 - 剩余参数,Array的扩展方法,String的扩展方法
MySQL忘记密码怎么办
2021新版idea过滤无用文件.idea .iml
Scala 基础 (三):运算符和流程控制
pyspark---对suuid区间编码(基于曝光数、点击数)
el-table gets the data attribute of a row in the read data table
一家可靠的HDI板厂,需要具备哪些基本条件?
Redis-记一次docker下使用redis
mysql事务与多版本并发控制
随机推荐
保姆级讲解Transformer
Command errored out with exit status 1类似问题解决方案
2021新版idea过滤无用文件.idea .iml
MySQL的 DDL和DML和DQL的基本语法
【dllogger bug】AttributeError: module ‘dllogger‘ has no attribute ‘StdOutBackend‘
cnpm的安装与使用
高密度 PCB 线路板设计中的过孔知识
el-tree设置选中高亮焦点高亮、选中的节点加深背景,更改字体颜色等
El - table column filter functions, control columns show and hide (effect and easy to implement full marks)
mysql 时间字段默认设置为当前时间
UniApp scroll-view 事件不生效(@scroll、@scrolltolower、@scrolltoupper ...)
IPV4地址详解
【EA Price strategy OC1】以实时价格为依据的EA,首月翻仓!】
Shell脚本--信号发送与捕捉
HDI与普通PCB的4点主要区别
empty() received an invalid combination of arguments - got (tuple, dtype=NoneType, device=NoneType),
PCB板上的字母代表哪些元器件?一文看全!
Postman知识汇总
MySQL性能优化(硬件,系统配置,表结构,SQL语句)
信息学奥赛一本通T1448:深搜的剪枝技巧 电路维修