// Define the template
    <template>
         <div>
             <el-tree                  
                :data="tree.treeData"           
                :props="tree.treeDataProps"
                node-key="_id"
                accordion
                ref="tree"   
                :expand-on-click-node="false"
                highlight-current                     
                >
                 <template  #default="{ node, data }">               
                        <span class="custom-tree-node">   
                               {{ data.name }}   
                        </span>
                    </template>
                </el-tree>
         </div>   
    </template>
    
    // Define data
    setup(){
        const tree = reactive({
                    treeData: []./ / tree
                    treeDataProps: {
                        label: 'name'.children: 'children'.id: '_id'}})}// method callTreeDataList (list data)// The data is converted into a tree
            const treeDataList = (data) = >{
                // Store data as map index data column with id as KEY
                let map = {};
                data.forEach(function (item) {
                    map[item._id.toString()] = item;
                });
                let val = [];
                for (let item of data) {
                    // Find the index ID in the map object with parentId of the current traversal item
                    let parent = map[item.parentId];
                    // If the index is found, then the item is not in the top level, so we need to add the item to its parent
                    if (parent) {
                        (parent.children || (parent.children = [])).push(item);
                    } else {
                    // If no index ID is found in the map, add the current item directly to the val result set as the top level
                    val.push(item);
                    }
                }
                proxy.$nextTick(() = >{
                     tree.treeData = val // Data in the tree})}Copy the code