做富文本编辑器时,需要将文本里的标题整理成树形数据, // 这里是数据结构 const data = [ { "id": "hkyrq2ndc-36yttda0lme00", "text": "阿萨德阿萨德阿萨", "level": 1, "depth": 1, }, { "id": "h4kgw8yp6-5cjohrp4xek00", "text": "阿萨德阿萨德阿萨", "level": 3, "depth": 3, }, { "id": "h4kgw8yp6-8yz253xo1ds00",