1. 原生 封裝工具函數(shù) getTree
1.1 定義 -映射對(duì)象 map? ?數(shù)組treeList=[]
1.2 遍歷 后端返回的數(shù)組 list? 為 每個(gè)數(shù)組對(duì)象item 添加 children 屬性 值為空數(shù)組?

1.3? 為映射對(duì)象 map 添加屬性 并賦值? key:id值? value:item??

1.4 遍歷數(shù)組對(duì)象list? 當(dāng)item.pid為空時(shí)? 為一級(jí)目錄? ?將該一級(jí)目錄數(shù)組對(duì)象? 添加到treeList中

1.5? 通過(guò) item.pid獲取到 id 不為空時(shí) 獲取數(shù)組對(duì)象? pid為01

1.6? 獲取 映射對(duì)象 map 獲取到 屬性名01? ? 將該數(shù)組對(duì)象item 添加 到children中 并返回到?treeList中
? ? ?代碼:

結(jié)構(gòu)圖:
