A few lines of code at the top of the iview document, asking for an explanation

Delete the code of a node in tree component in

iview, and explain how to get parent.

remove (root, node, data) {
    const parentKey = root.find(el => el === node).parent;
    const parent = root.find(el => el.nodeKey === parentKey).node;
    const index = parent.children.indexOf(data);
    parent.children.splice(index, 1);
}
Sep.24,2021

1.root should actually be the root node, and a function
2 is passed into the find method. Traverse all nodes from the root node and return the nodes that meet the criteria


translate this paragraph sentence by sentence:

remove (root, node, data) {
    // node.parentparentKey
    const parentKey = root.find(el => el === node).parent;
    // nodeKeyparentKey
    const parent = root.find(el => el.nodeKey === parentKey).node;
    // data
    const index = parent.children.indexOf(data);
    // 
    parent.children.splice(index, 1);
}

from the logic inside the parameters and methods, we can see that the method of removing an element is to delete a node by using the root node as the benchmark, locating the parent according to a child node passed in, and then judging the location of the deleted element based on the passed data. The data structures used in this logic are formatted within iview during component initialization.


remove (root, node, data) {

// node.parentparentKey
const parentKey = root.find(el => el === node).parent;
// nodeKeyparentKey
const parent = root.find(el => el.nodeKey === parentKey).node;
// data
const index = parent.children.indexOf(data);
// 
parent.children.splice(index, 1);

}

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eb3e95-471d4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eb3e95-471d4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?