当前位置:网站首页>Parent and child of treeselect
Parent and child of treeselect
2022-07-28 13:20:00 【Pig Xiaoyong】
List of articles
TreeSelect
TreeSelect You need to send the results of both the parent and child to the background , So the child id Splicing . Parent id- Sub level id.
Notice a pit here , Parent and child id May repeat , So when rendering, you need to set the sub level id Perform mosaic rendering , Otherwise, the reverse display error will occur .
TreeSelect Reverse attention : The father key And value, It's the only one , All need to be spliced .
// buList=['1-1', '1-2', '2-1', '2-2']
// buList = [
// {
// id,
// name,
// children: [{
// id,
// nameA
// }, {
// id,
// nameA
// }]
// },
// {
// id,
// name,
// children: [{
// id,
// name
// }, {
// id,
// name
// }]
// }
// ]
//--- Split parent and child
let splitObj = values.buList.map(item => {
let line = item.split("-");
let obj = {
father: line[0],
son: line[1]
}
return obj
})
let skilled = [] // Be good at the field
treeData.forEach(item => {
let ab = splitObj.filter(ite => {
return ite.father == item.key
})
// Use traversal to find whether there is a parent id Same , Traversal when there is children, There is no return Traverse to the next item
// filter() Method to create a new array , The elements in the new array are checked by checking all the eligible elements in the specified array .
if (ab.length < 1) {
return
}
let obj = {
id: item.key,
name: item.title,
children: []
}
item.children.forEach(ite => {
values.buList.forEach(i => {
if (ite.key == i) {
obj.children.push(ite);
}
})
})
skilled.push(obj);
})
values.buList = skilled;
1.splitObj:
filter() The elements passed later are also these , This is a ab Result 
2.item.children:

3.values.buList

4.treeData:

边栏推荐
- The essence of enterprise Digitalization
- 【嵌入式C基础】第5篇:原码/反码/补码
- Redis —— 基础篇
- MySQL practice -- master-slave replication
- QT signal and slot mechanism (detailed)
- I copied the bottom of the liquidated NFT, but was locked by opensea
- [embedded C foundation] Part 5: original code / inverse code / complement code
- [FPGA]: Joint Simulation of FPGA and MATLAB
- Margin calculation
- Pointnet++ Chinese Translation
猜你喜欢

Bull spread portfolio

leetcdoe-342. 4的幂

Change the document type in endnode and import it in word

Intrinsic value and time value of options

How to design a second kill system?

How does kotlin help you avoid memory leaks?

Tidb 6.x in action was released, a summary of 6.x practices that condense the collective wisdom of the community!

Led aquarium lamp touch chip-dlt8t02s-jericho

Have a part of the game, after NFT is disabled in my world

GameStop熊市杀入NFT交易,老牌游戏零售商借Web3焕发第二春
随机推荐
Resolve browser password echo
Compare the new and old data to find the added and deleted ones
我抄底了被清算的NFT,却被OpenSea上了锁
Led aquarium lamp touch chip-dlt8t02s-jericho
[embedded C foundation] Part 5: original code / inverse code / complement code
拥有游戏的一部分,写在我的世界禁用NFT之后
Low code: reduce technical capability requirements and improve software development efficiency
Black Scholes Merton European option pricing formula
黑猫带你学eMMC协议第26篇:eMMC的硬件复位操作(H/W reset)
The difference between sessionstorage, localstorage and cookies
[embedded C foundation] Part 1: basic data types
Stepless dimming colorful RGB mirror light touch chip-dlt8s12a-jericho
Change password, confirm password verification antd
Databinding+livedata can easily realize skin changing without restart
Full disclosure! Huawei cloud distributed cloud native technology and Practice
Original juice multifunctional Juicer touch chip-dlt8t02s-jericho
2020jenkins study notes
机器学习基础-集成学习-13
Why neural networks are ineffective?
[basic teaching of Bi design] detailed explanation of OLED screen use - single chip microcomputer Internet of things