Parse the data containing children to form the structure required by iview's cascader or tree row

function convertTree (rst) {
    const result = []

    // traverse the tree
    rst.forEach((item) => {         // destructuring assignment         let {             value: value,             label: label,             children: children         } = item;





        // If there are children, recurse
        if (children) {             children = convertTree(children);         }

        result.push({
            value,
            label,
            children
        })
    })

    return result;
}

Guess you like

Origin blog.csdn.net/xiansibao/article/details/130284311