当前位置:网站首页>Convert the array selected by El tree into an array object
Convert the array selected by El tree into an array object
2022-07-06 06:20:00 【Don't sleep I】
problem :
el-tree Render according to the structure of the array object , When we check the desired data, only an array will be generated
Desired effect :
Get the selected data ( Array ), According to the father A Inferior son a Structure , Perform data structure conversion corresponding to parent-child level
My data structure :
Post code : Direct copy , Change the variable name to use
<el-tree
:data="collectionListData"
show-checkbox
node-key="id"
@check="checkFn"
ref="tree"
:props="defaultProps">
</el-tree>
// In the following code devices Is my child array data , Remember to change
checkFn(data, node) {
let nodearr = [];
if (!node.halfCheckedKeys.length) {
node.checkedNodes.forEach((item) => {
if (item.devices) {
nodearr.push(item);
}
});
} else {
let nodeCheckedNodes = node.checkedNodes;
let nodeHalfCheckedNodes = node.halfCheckedNodes;
nodeHalfCheckedNodes.forEach((item) => {
let assign = Object.assign({
}, item);
assign.devices = [];
let childrenLength = item.devices;
for (let i = 0; i < nodeCheckedNodes.length; i++) {
if (nodeCheckedNodes[i].devices) {
nodearr.push(nodeCheckedNodes[i]);
} else {
for (let j = 0; j < childrenLength.length; j++) {
if (nodeCheckedNodes[i].id != childrenLength[j].id) {
continue;
} else {
assign.devices.push(childrenLength[j]);
}
}
}
}
nodearr.push(assign);
});
}
this.nodeList = nodearr;
},
边栏推荐
- Reading notes of effective managers
- An article was uncovered to test the truth of outsourcing companies
- 进程和线程的理解
- Summary of anomaly detection methods
- Testing of web interface elements
- Cannot create PoolableConnectionFactory (Could not create connection to database server. 错误
- LeetCode 732. 我的日程安排表 III
- 模拟卷Leetcode【普通】1314. 矩阵区域和
- Simulation volume leetcode [general] 1143 Longest common subsequence
- 黑猫带你学UFS协议第18篇:UFS如何配置逻辑单元(LU Management)
猜你喜欢
Past and present lives of QR code and sorting out six test points
win10无法操作(删除、剪切)文件
把el-tree选中的数组转换为数组对象
Play video with Tencent video plug-in in uni app
Manage configuration using Nacos
调用链监控Zipkin、sleuth搭建与整合
sourceInsight中文乱码
[eolink] PC client installation
进程和线程的理解
CoordinatorLayout+NestedScrollView+RecyclerView 上拉底部显示不全
随机推荐
Thoughts on data security (Reprint)
Basic knowledge of error
【Postman】测试(Tests)脚本编写和断言详解
QT: the program input point xxxxx cannot be located in the dynamic link library.
sourceInsight中文乱码
Redis core technology and basic architecture of actual combat: what does a key value database contain?
G - Supermarket
Application du Groupe Li dans gtsam
MFC on the conversion and display of long string unsigned char and CString
D - How Many Answers Are Wrong
Still worrying about how to write web automation test cases? Senior test engineers teach you selenium test case writing hand in hand
Hypothesis testing learning notes
模拟卷Leetcode【普通】1109. 航班预订统计
B - The Suspects
Properties file
The latest 2022 review of "graph classification research"
还在为如何编写Web自动化测试用例而烦恼嘛?资深测试工程师手把手教你Selenium 测试用例编写
Pat (Grade B) 2022 summer exam
LeetCode 1200. 最小绝对差
Aike AI frontier promotion (2.13)