当前位置:网站首页>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;
},
边栏推荐
- Web界面元素的测试
- leaflet 地图
- 模拟卷Leetcode【普通】1414. 和为 K 的最少斐波那契数字数目
- Past and present lives of QR code and sorting out six test points
- Cannot create PoolableConnectionFactory (Could not create connection to database server. 错误
- Career advancement Guide: recommended books for people in big factories
- 10m25dcf484c8g (FPGA) amy-6m-0002 BGA GPS module
- Qt:无法定位程序输入点XXXXX于动态链接库。
- [postman] collections configuration running process
- 10M25DCF484C8G(FPGA) AMY-6M-0002 BGA GPS模块
猜你喜欢
[no app push general test plan
Understanding of processes and threads
JWT-JSON WEB TOKEN
Fault, error, failure of functional safety
浅谈专项测试之弱网络测试
Career advancement Guide: recommended books for people in big factories
The latest 2022 review of "graph classification research"
Detailed explanation of P problem, NP problem, NPC problem and NP hard problem
进程和线程的理解
数据库隔离级别
随机推荐
这些年用Keil遇到的坑
leaflet 地图
数据库-当前读与快照读
Properties file
通过修改style设置打印页样式
模拟卷Leetcode【普通】1218. 最长定差子序列
Nodejs realizes the third-party login of Weibo
win10无法操作(删除、剪切)文件
Online and offline problems
ESP32 ESP-IDF看门狗TWDT
ICLR 2022 spotlight | analog transformer: time series anomaly detection method based on correlation difference
「 WEB测试工程师 」岗位一面总结
Simulation volume leetcode [general] 1218 Longest definite difference subsequence
Left matching principle of joint index
[C language] qsort function
G - Supermarket
Manhattan distance and Manhattan rectangle - print back font matrix
Summary of anomaly detection methods
Is the test cycle compressed? Teach you 9 ways to deal with it
Application of Lie group in gtsam